"""Test the `convert_units`""" from helpers.dimensions import UNIT_CONVERSIONS as dimension_unit_conversions from helpers.weight import UNIT_CONVERSIONS as weight_unit_conversions from helpers.misc import convert_units def test_units_to_cm_inches(): """Test `convert_units` to cm from inches""" assert convert_units(0.5, "inches", dimension_unit_conversions) == 1.27 def test_units_to_cm_feet(): """Test `convert_units` to cm from feet""" assert convert_units(0.5, "feet", dimension_unit_conversions) == 15.24 def test_units_to_cm_cm(): """Test `convert_units` to cm from cm""" assert convert_units(0.5, "cm", dimension_unit_conversions) == 0.5 def test_units_to_cm_unrecognized(): """Test `convert_units` to cm from unrecognized unit""" assert convert_units(0.5, "yards", dimension_unit_conversions) is None def test_units_to_g_pounds(): """Test `convert_units` to g from pounds""" assert convert_units(0.5, "pounds", weight_unit_conversions) == 226.8 def test_units_to_g_ounces(): """Test `convert_units` to g from ounces""" assert convert_units(0.5, "ounces", weight_unit_conversions) == 14.17 def test_units_to_g_g(): """Test `convert_units` to g from g""" assert convert_units(0.5, "g", weight_unit_conversions) == 0.5 def test_units_to_g_kg(): """Test `convert_units` to g from kg""" assert convert_units(0.5, "kg", weight_unit_conversions) == 500 def test_units_to_g_unrecognized(): """Test `convert_units` to g from unrecognized unit""" assert convert_units(0.5, "mg", weight_unit_conversions) is None