Skip to content

Commit

Permalink
TST: add flight fixture for solid propulsion equations of motion
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Dec 16, 2024
1 parent 2218f0f commit c204702
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
16 changes: 16 additions & 0 deletions tests/fixtures/flight/flight_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ def flight_calisto_robust(calisto_robust, example_spaceport_env):
)


@pytest.fixture
def flight_calisto_robust_solid_eom(calisto_robust, example_spaceport_env):
"""Similar to flight_calisto_robust, but with the equations of motion set to
"solid_propulsion".
"""
return Flight(
environment=example_spaceport_env,
rocket=calisto_robust,
rail_length=5.2,
inclination=85,
heading=0,
terminate_on_apogee=False,
equations_of_motion="solid_propulsion",
)


@pytest.fixture
def flight_calisto_custom_wind(calisto_robust, example_spaceport_env):
"""A rocketpy.Flight object of the Calisto rocket. This uses the calisto
Expand Down
15 changes: 10 additions & 5 deletions tests/integration/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
plt.rcParams.update({"figure.max_open_warning": 0})


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


@pytest.mark.slow
Expand Down

0 comments on commit c204702

Please sign in to comment.