diff --git a/.github/workflows/test_pytest.yaml b/.github/workflows/test_pytest.yaml index e5b944317..b02aa5f03 100644 --- a/.github/workflows/test_pytest.yaml +++ b/.github/workflows/test_pytest.yaml @@ -76,6 +76,10 @@ jobs: - name: Run Unit Tests run: pytest tests/unit --cov=rocketpy + # The changelog workflow only runs after a merge, so its script is tested here. + - name: Test the changelog script + run: pytest .github/scripts/test_update_changelog.py + - name: Run Documentation Tests run: | pip install numpy --upgrade diff --git a/requirements-optional.txt b/requirements-optional.txt index d1d95b2e6..e47096ff2 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -9,4 +9,5 @@ statsmodels prettytable contextily>=1.0.0; python_version < '3.14' pyvista>=0.45 -imageio-ffmpeg>=0.5 \ No newline at end of file +imageio-ffmpeg>=0.5 +folium>=0.14 diff --git a/tests/acceptance/test_defiance_rocket.py b/tests/acceptance/test_defiance_rocket.py index 1afe5143d..e10dabc09 100644 --- a/tests/acceptance/test_defiance_rocket.py +++ b/tests/acceptance/test_defiance_rocket.py @@ -1,4 +1,4 @@ -"""Acceptance test for the 2024 Defiance example flight.""" +"""Defiance 2024 flight: apogee against the measured flight, the rest as a regression.""" import pytest @@ -9,12 +9,12 @@ MEASURED_APOGEE_AGL = 9308.32 MAX_RELATIVE_APOGEE_ERROR = 0.01 -REFERENCE_MAX_SPEED = 444.24 -REFERENCE_MAX_ACCELERATION = 10400.76 -REFERENCE_IMPACT_X = 1550.23 -REFERENCE_IMPACT_Y = 104.80 -REFERENCE_METRIC_RELATIVE_TOLERANCE = 0.01 -REFERENCE_IMPACT_ABSOLUTE_TOLERANCE = 3.0 +# RocketPy's own output, not flight data: they only catch unintended changes. +REGRESSION_MAX_SPEED = 444.24 +REGRESSION_IMPACT_X = 1550.23 +REGRESSION_IMPACT_Y = 104.80 +REGRESSION_RELATIVE_TOLERANCE = 0.01 +REGRESSION_IMPACT_ABSOLUTE_TOLERANCE = 3.0 def _build_defiance_flight(): @@ -122,21 +122,18 @@ def test_defiance_rocket_apogee_matches_measured_flight(defiance_flight): ) -def test_defiance_rocket_matches_reference_flight_metrics(defiance_flight): - """Guard the deterministic example's peak and impact metrics.""" - tolerance = {"rel": REFERENCE_METRIC_RELATIVE_TOLERANCE} +def test_defiance_rocket_regression_flight_metrics(defiance_flight): + """Guard the example's max speed and impact point against unintended changes.""" + tolerance = {"rel": REGRESSION_RELATIVE_TOLERANCE} impact_tolerance = { **tolerance, - "abs": REFERENCE_IMPACT_ABSOLUTE_TOLERANCE, + "abs": REGRESSION_IMPACT_ABSOLUTE_TOLERANCE, } - assert defiance_flight.max_speed == pytest.approx(REFERENCE_MAX_SPEED, **tolerance) - assert defiance_flight.max_acceleration == pytest.approx( - REFERENCE_MAX_ACCELERATION, **tolerance - ) + assert defiance_flight.max_speed == pytest.approx(REGRESSION_MAX_SPEED, **tolerance) assert defiance_flight.x_impact == pytest.approx( - REFERENCE_IMPACT_X, **impact_tolerance + REGRESSION_IMPACT_X, **impact_tolerance ) assert defiance_flight.y_impact == pytest.approx( - REFERENCE_IMPACT_Y, **impact_tolerance + REGRESSION_IMPACT_Y, **impact_tolerance ) diff --git a/tests/fixtures/environment/environment_fixtures.py b/tests/fixtures/environment/environment_fixtures.py index 2679e3ca3..088f56f85 100644 --- a/tests/fixtures/environment/environment_fixtures.py +++ b/tests/fixtures/environment/environment_fixtures.py @@ -116,7 +116,7 @@ def env_analysis(): end_hour=18, surface_data_file="./data/weather/EuroC_single_level_reanalysis_2002_2021.nc", pressure_level_data_file="./data/weather/EuroC_pressure_levels_reanalysis_2001-2021.nc", - timezone=None, + timezone="Europe/Lisbon", # what timezonefinder gives, without needing it unit_system="metric", forecast_date=None, forecast_args=None, diff --git a/tests/integration/environment/test_environment_analysis.py b/tests/integration/environment/test_environment_analysis.py index 6e3a76aef..958f82bed 100644 --- a/tests/integration/environment/test_environment_analysis.py +++ b/tests/integration/environment/test_environment_analysis.py @@ -3,12 +3,14 @@ from unittest.mock import patch import matplotlib as plt +import pytest from rocketpy import Environment plt.rcParams.update({"figure.max_open_warning": 0}) +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_all_info(mock_show, env_analysis): # pylint: disable=unused-argument """Test the EnvironmentAnalysis.all_info() method, which already invokes @@ -24,12 +26,16 @@ def test_all_info(mock_show, env_analysis): # pylint: disable=unused-argument ------- None """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") assert env_analysis.info() is None assert env_analysis.all_info() is None assert env_analysis.plots.info() is None os.remove("wind_rose.gif") # remove the files created by the method +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument """Check the export methods of the EnvironmentAnalysis class. It @@ -42,6 +48,10 @@ def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument env_analysis : EnvironmentAnalysis A simple object of the EnvironmentAnalysis class. """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") + pytest.importorskip("jsonpickle") assert env_analysis.export_mean_profiles() is None assert env_analysis.save("env_analysis_dict") is None @@ -56,6 +66,7 @@ def test_exports(mock_show, env_analysis): # pylint: disable=unused-argument os.remove("export_env_analysis.json") +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_create_environment_object(mock_show, env_analysis): # pylint: disable=unused-argument assert isinstance(env_analysis.create_environment_object(), Environment) diff --git a/tests/unit/environment/test_environment_analysis.py b/tests/unit/environment/test_environment_analysis.py index dda5df31b..cc5c22af6 100644 --- a/tests/unit/environment/test_environment_analysis.py +++ b/tests/unit/environment/test_environment_analysis.py @@ -48,6 +48,7 @@ def test_missing_timezonefinder_defaults_to_utc( assert analysis.end_date.tzinfo is not None +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_distribution_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Tests the distribution plots method of the EnvironmentAnalysis class. It @@ -78,6 +79,7 @@ def test_distribution_plots(mock_show, env_analysis): # pylint: disable=unused- ) +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Tests the average plots method of the EnvironmentAnalysis class. It @@ -94,6 +96,7 @@ def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argum ------- None """ + pytest.importorskip("windrose") # Check "average" plots assert env_analysis.plots.average_surface_temperature_evolution() is None assert env_analysis.plots.average_surface10m_wind_speed_evolution(False) is None @@ -103,6 +106,7 @@ def test_average_plots(mock_show, env_analysis): # pylint: disable=unused-argum assert env_analysis.plots.average_wind_rose_specific_hour(12) is None +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_profile_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Check the profile plots method of the EnvironmentAnalysis class. It @@ -144,6 +148,7 @@ def test_profile_plots(mock_show, env_analysis): # pylint: disable=unused-argum ) +@pytest.mark.slow def test_values(env_analysis): """Check the numeric properties of the EnvironmentAnalysis class. It computes a few values and compares them to the expected values. Not all the values are @@ -167,6 +172,7 @@ def test_values(env_analysis): assert pytest.approx(env_analysis.std_pressure_at_30000ft, 1e-6) == 38.48947 +@pytest.mark.slow @patch("matplotlib.pyplot.show") def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-argument """Check the animation plots method of the EnvironmentAnalysis class. It @@ -181,6 +187,9 @@ def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-arg env_analysis : EnvironmentAnalysis A simple object of the EnvironmentAnalysis class. """ + pytest.importorskip("windrose") + pytest.importorskip("ipywidgets") + pytest.importorskip("IPython") # import dependencies widgets = import_optional_dependency("ipywidgets") HTML = import_optional_dependency("IPython.display").HTML @@ -197,6 +206,7 @@ def test_animation_plots(mock_show, env_analysis): # pylint: disable=unused-arg os.remove("wind_rose.gif") # remove the files created by the method +@pytest.mark.slow def test_pressure_level_wind_profile_uses_velocity_components(env_analysis): """Regression for PR #1041: the redundant per-level ``wind_heading`` and ``wind_direction`` functions were removed from the pressure-level data.