Skip to content

Commit b9ac8e6

Browse files
TST: tests for the new feature
1 parent 54b706a commit b9ac8e6

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/test_flight.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,48 @@ def test_initial_solution(mock_show, example_env, calisto_robust):
141141
assert test_flight.all_info() == None
142142

143143

144+
def test_get_solution_at_time(flight_calisto):
145+
"""Test the get_solution_at_time method of the Flight class. This test
146+
simply calls the method at the initial and final time and checks if the
147+
returned values are correct.
148+
149+
Parameters
150+
----------
151+
flight_calisto : rocketpy.Flight
152+
Flight object to be tested. See the conftest.py file for more info
153+
regarding this pytest fixture.
154+
"""
155+
assert np.allclose(
156+
flight_calisto.get_solution_at_time(0),
157+
np.array([0, 0, 0, 0, 0, 0, 0, 0.99904822, -0.04361939, 0, 0, 0, 0, 0]),
158+
rtol=1e-05,
159+
atol=1e-08,
160+
)
161+
assert np.allclose(
162+
flight_calisto.get_solution_at_time(flight_calisto.t_final),
163+
np.array(
164+
[
165+
48.4313533,
166+
0.0,
167+
985.755944,
168+
-0.00000229951048,
169+
0.0,
170+
11.2223284,
171+
-341.028803,
172+
0.999048222,
173+
-0.0436193874,
174+
0.0,
175+
0.0,
176+
0.0,
177+
0.0,
178+
0.0,
179+
]
180+
),
181+
rtol=1e-05,
182+
atol=1e-05,
183+
)
184+
185+
144186
@pytest.mark.parametrize("wind_u, wind_v", [(0, 10), (0, -10), (10, 0), (-10, 0)])
145187
@pytest.mark.parametrize(
146188
"static_margin, max_time",

0 commit comments

Comments
 (0)