|
| 1 | +import warnings |
1 | 2 | from unittest.mock import patch |
2 | 3 |
|
3 | 4 | import numpy as np |
@@ -370,6 +371,39 @@ def test_add_motor(calisto_motorless, cesaroni_m1670): |
370 | 371 | assert center_of_mass_motorless is not center_of_mass_with_motor |
371 | 372 |
|
372 | 373 |
|
| 374 | +def test_check_missing_all_components(calisto_motorless): |
| 375 | + """Tests the _check_missing_components method for a Rocket with no components.""" |
| 376 | + with pytest.warns(UserWarning) as record: |
| 377 | + calisto_motorless._check_missing_components() |
| 378 | + |
| 379 | + assert len(record) == 1 |
| 380 | + msg = str(record[0].message) |
| 381 | + assert "motor" in msg |
| 382 | + assert "aerodynamic surfaces" in msg |
| 383 | + |
| 384 | + |
| 385 | +def test_check_missing_some_components(calisto): |
| 386 | + """Tests the _check_missing_components method for a Rocket missing some components.""" |
| 387 | + calisto.aerodynamic_surfaces = [] |
| 388 | + |
| 389 | + with pytest.warns(UserWarning) as record: |
| 390 | + calisto._check_missing_components() |
| 391 | + |
| 392 | + assert len(record) == 1 |
| 393 | + msg = str(record[0].message) |
| 394 | + assert "aerodynamic surfaces" in msg |
| 395 | + |
| 396 | + |
| 397 | +def test_check_missing_no_components_missing(calisto_robust): |
| 398 | + """Tests the _check_missing_components method for a complete Rocket.""" |
| 399 | + # Catch all warnings that occur inside this 'with' block. |
| 400 | + with warnings.catch_warnings(record=True) as w: |
| 401 | + warnings.simplefilter("always") |
| 402 | + calisto_robust._check_missing_components() |
| 403 | + # For a complete rocket, this method should NOT issue any warnings. |
| 404 | + assert len(w) == 0 |
| 405 | + |
| 406 | + |
373 | 407 | def test_set_rail_button(calisto): |
374 | 408 | rail_buttons = calisto.set_rail_buttons(0.2, -0.5, 30) |
375 | 409 | # assert buttons_distance |
|
0 commit comments