Skip to content

Commit

Permalink
test(test_main.py): improve mean speed test with parametrization
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoirand committed Apr 1, 2024
1 parent 67e6822 commit 70b5614
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@

# third party
import numpy as np
import pytest

# current project
from duventchezmoi.main import compute_mean_wind_speed
from duventchezmoi.main import write_report


def test_compute_mean_speed():
@pytest.mark.parametrize("units, expected_result", [("km/h", 18.65), ("m/s", 5.18)])
def test_compute_mean_speed(units, expected_result):
grib2_file = Path(__file__).parent / "20240330_0000.grib2"
units = "km/h"
expected_result = 18.65
value = compute_mean_wind_speed(grib2_file, units)
assert np.round(value, decimals=2) == expected_result
units = "m/s"
expected_result = 5.18
value = compute_mean_wind_speed(grib2_file, units)
assert np.round(value, decimals=2) == expected_result

Expand Down

0 comments on commit 70b5614

Please sign in to comment.