Refactor distance, speed and volume utils (#77952)

* Refactor distance util

* Fix bmw connected drive tests

* Adjust here travel time tests

* Adjust waze travel time tests

* Adjust test_distance

* Adjust rounding values

* Adjust more tests

* Adjust volume conversions

* Add tests
This commit is contained in:
epenet 2022-09-07 16:18:00 +02:00 committed by GitHub
parent 01f1629ac0
commit 9490771a87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 248 additions and 131 deletions

View file

@ -177,13 +177,17 @@ def test_length_unknown_unit():
def test_length_to_metric():
"""Test length conversion to metric system."""
assert METRIC_SYSTEM.length(100, METRIC_SYSTEM.length_unit) == 100
assert METRIC_SYSTEM.length(5, IMPERIAL_SYSTEM.length_unit) == 8.04672
assert METRIC_SYSTEM.length(5, IMPERIAL_SYSTEM.length_unit) == pytest.approx(
8.04672
)
def test_length_to_imperial():
"""Test length conversion to imperial system."""
assert IMPERIAL_SYSTEM.length(100, IMPERIAL_SYSTEM.length_unit) == 100
assert IMPERIAL_SYSTEM.length(5, METRIC_SYSTEM.length_unit) == 3.106855
assert IMPERIAL_SYSTEM.length(5, METRIC_SYSTEM.length_unit) == pytest.approx(
3.106855
)
def test_wind_speed_unknown_unit():