Skip to content

Commit 9b65393

Browse files
TST: add flight fixture for solid propulsion equations of motion
1 parent c7f1623 commit 9b65393

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

tests/fixtures/flight/flight_fixtures.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ def flight_calisto_robust(calisto_robust, example_spaceport_env):
9393
)
9494

9595

96+
@pytest.fixture
97+
def flight_calisto_robust_solid_eom(calisto_robust, example_spaceport_env):
98+
"""Similar to flight_calisto_robust, but with the equations of motion set to
99+
"solid_propulsion".
100+
"""
101+
return Flight(
102+
environment=example_spaceport_env,
103+
rocket=calisto_robust,
104+
rail_length=5.2,
105+
inclination=85,
106+
heading=0,
107+
terminate_on_apogee=False,
108+
equations_of_motion="solid_propulsion",
109+
)
110+
111+
96112
@pytest.fixture
97113
def flight_calisto_custom_wind(calisto_robust, example_spaceport_env):
98114
"""A rocketpy.Flight object of the Calisto rocket. This uses the calisto

tests/integration/test_flight.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
plt.rcParams.update({"figure.max_open_warning": 0})
1111

1212

13+
@pytest.mark.parametrize(
14+
"flight_fixture", ["flight_calisto_robust", "flight_calisto_robust_solid_eom"]
15+
)
1316
@patch("matplotlib.pyplot.show")
1417
# pylint: disable=unused-argument
15-
def test_all_info(mock_show, flight_calisto_robust):
18+
def test_all_info(mock_show, request, flight_fixture):
1619
"""Test that the flight class is working as intended. This basically calls
1720
the all_info() method and checks if it returns None. It is not testing if
1821
the values are correct, but whether the method is working without errors.
@@ -21,11 +24,13 @@ def test_all_info(mock_show, flight_calisto_robust):
2124
----------
2225
mock_show : unittest.mock.MagicMock
2326
Mock object to replace matplotlib.pyplot.show
24-
flight_calisto_robust : rocketpy.Flight
25-
Flight object to be tested. See the conftest.py file for more info
26-
regarding this pytest fixture.
27+
request : _pytest.fixtures.FixtureRequest
28+
Request object to access the fixture dynamically.
29+
flight_fixture : str
30+
Name of the flight fixture to be tested.
2731
"""
28-
assert flight_calisto_robust.all_info() is None
32+
flight = request.getfixturevalue(flight_fixture)
33+
assert flight.all_info() is None
2934

3035

3136
@pytest.mark.slow

0 commit comments

Comments
 (0)