def test_accumulated_precipitation_to_metric(): """Test accumulated_precipitation conversion to metric system.""" assert (METRIC_SYSTEM.accumulated_precipitation( 25, METRIC_SYSTEM.accumulated_precipitation_unit) == 25) assert METRIC_SYSTEM.accumulated_precipitation( 10, IMPERIAL_SYSTEM.accumulated_precipitation_unit) == pytest.approx( 254, abs=1e-4)
def test_invalid_value(): """Test no conversion happens if value is non-numeric.""" with pytest.raises(TypeError): METRIC_SYSTEM.length("25a", LENGTH_KILOMETERS) with pytest.raises(TypeError): METRIC_SYSTEM.temperature("50K", TEMP_CELSIUS) with pytest.raises(TypeError): METRIC_SYSTEM.wind_speed("50km/h", SPEED_METERS_PER_SECOND) with pytest.raises(TypeError): METRIC_SYSTEM.volume("50L", VOLUME_LITERS) with pytest.raises(TypeError): METRIC_SYSTEM.pressure("50Pa", PRESSURE_PA) with pytest.raises(TypeError): METRIC_SYSTEM.accumulated_precipitation("50mm", LENGTH_MILLIMETERS)
def test_accumulated_precipitation_unknown_unit(): """Test no conversion happens if unknown unit.""" with pytest.raises(ValueError): METRIC_SYSTEM.accumulated_precipitation(5, "K")
def test_accumulated_precipitation_same_unit(): """Test no conversion happens if to unit is same as from unit.""" assert (METRIC_SYSTEM.accumulated_precipitation( 5, METRIC_SYSTEM.accumulated_precipitation_unit) == 5)