Increase code coverage for migrated utilities (#78990)

Increase code coverage for migrated utilites
pull/79012/head
epenet 2022-09-23 17:32:59 +02:00 committed by GitHub
parent ffd88ab50e
commit 62022a2657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -8,6 +8,23 @@ INVALID_SYMBOL = "bob"
VALID_SYMBOL = TEMP_CELSIUS
@pytest.mark.parametrize(
"function_name, value, expected",
[
("fahrenheit_to_celsius", 75.2, 24),
("kelvin_to_celsius", 297.65, 24.5),
("celsius_to_fahrenheit", 23, 73.4),
("celsius_to_kelvin", 23, 296.15),
],
)
def test_deprecated_functions(
function_name: str, value: float, expected: float
) -> None:
"""Test that deprecated function still work."""
convert = getattr(temperature_util, function_name)
assert convert(value) == expected
def test_convert_same_unit():
"""Test conversion from any unit to same unit."""
assert temperature_util.convert(2, TEMP_CELSIUS, TEMP_CELSIUS) == 2

View File

@ -16,6 +16,23 @@ INVALID_SYMBOL = "bob"
VALID_SYMBOL = VOLUME_LITERS
@pytest.mark.parametrize(
"function_name, value, expected",
[
("liter_to_gallon", 2, pytest.approx(0.528344)),
("gallon_to_liter", 2, 7.570823568),
("cubic_meter_to_cubic_feet", 2, pytest.approx(70.629333)),
("cubic_feet_to_cubic_meter", 2, pytest.approx(0.0566337)),
],
)
def test_deprecated_functions(
function_name: str, value: float, expected: float
) -> None:
"""Test that deprecated function still work."""
convert = getattr(volume_util, function_name)
assert convert(value) == expected
def test_convert_same_unit():
"""Test conversion from any unit to same unit."""
assert volume_util.convert(2, VOLUME_LITERS, VOLUME_LITERS) == 2