Skip to content

Commit db5aa9a

Browse files
committed
ENH:Add tests for _check_missing_components method in Rocket class
1 parent c0f17a5 commit db5aa9a

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

tests/unit/test_rocket.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111

1212
@patch("matplotlib.pyplot.show")
13-
def test_elliptical_fins(mock_show, calisto_robust, calisto_trapezoidal_fins): # pylint: disable=unused-argument
13+
def test_elliptical_fins(
14+
mock_show, calisto_robust, calisto_trapezoidal_fins
15+
): # pylint: disable=unused-argument
1416
test_rocket = calisto_robust
1517
calisto_robust.aerodynamic_surfaces.remove(calisto_trapezoidal_fins)
1618
test_rocket.add_elliptical_fins(4, span=0.100, root_chord=0.120, position=-1.168)
@@ -370,6 +372,40 @@ def test_add_motor(calisto_motorless, cesaroni_m1670):
370372
assert center_of_mass_motorless is not center_of_mass_with_motor
371373

372374

375+
def test_check_missing_all_components(calisto_motorless):
376+
"""Tests the _check_missing_components method for a Rocket with no components."""
377+
with pytest.warns(UserWarning) as record:
378+
calisto_motorless._check_missing_components()
379+
380+
assert len(record) == 1
381+
msg = str(record[0].message)
382+
assert "motor" in msg
383+
assert "parachutes" in msg
384+
assert "aerodynamic surfaces" in msg
385+
386+
387+
def test_check_missing_some_components(calisto):
388+
"""Tests the _check_missing_components method for a Rocket missing some components."""
389+
calisto.parachutes = []
390+
calisto.aerodynamic_surfaces = []
391+
392+
with pytest.warns(UserWarning) as record:
393+
calisto._check_missing_components()
394+
395+
assert len(record) == 1
396+
msg = str(record[0].message)
397+
assert "parachutes" in msg
398+
assert "aerodynamic surfaces" in msg
399+
400+
401+
def test_check_missing_no_components_missing(calisto_robust):
402+
"""Tests the _check_missing_components method for a complete Rocket."""
403+
# Call directly — no warnings expected
404+
calisto_robust._check_missing_components()
405+
# If any warning occurs, pytest will fail automatically
406+
assert True
407+
408+
373409
def test_set_rail_button(calisto):
374410
rail_buttons = calisto.set_rail_buttons(0.2, -0.5, 30)
375411
# assert buttons_distance

0 commit comments

Comments
 (0)