From 6779a3e191430ee1491d598af80184eb3c4de791 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Thu, 7 Mar 2024 18:37:20 -0500 Subject: [PATCH] TST: Add tests for initial and out-of-rail stability margins in Flight class --- tests/unit/test_flight.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/test_flight.py b/tests/unit/test_flight.py index 87249cf44..e6ab6b8b8 100644 --- a/tests/unit/test_flight.py +++ b/tests/unit/test_flight.py @@ -258,3 +258,31 @@ def test_get_controller_observed_variables(flight_calisto_air_brakes): obs_vars = flight_calisto_air_brakes.get_controller_observed_variables() assert isinstance(obs_vars, list) assert len(obs_vars) == 0 + + +def test_initial_stability_margin(flight_calisto_custom_wind): + """Test the initial_stability_margin method of the Flight class. + + Parameters + ---------- + flight_calisto_custom_wind : rocketpy.Flight + """ + res = flight_calisto_custom_wind.initial_stability_margin + assert isinstance(res, float) + assert res == flight_calisto_custom_wind.stability_margin(0) + assert np.isclose(res, 2.05, atol=0.1) + + +def test_out_of_rail_stability_margin(flight_calisto_custom_wind): + """Test the out_of_rail_stability_margin method of the Flight class. + + Parameters + ---------- + flight_calisto_custom_wind : rocketpy.Flight + """ + res = flight_calisto_custom_wind.out_of_rail_stability_margin + assert isinstance(res, float) + assert res == flight_calisto_custom_wind.stability_margin( + flight_calisto_custom_wind.out_of_rail_time + ) + assert np.isclose(res, 2.14, atol=0.1)