Skip to content

Commit a3e49a2

Browse files
TST: Add unit test for the Flight.export_pressures method
1 parent 60cae90 commit a3e49a2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ disable=raw-checker-failed,
435435
use-implicit-booleaness-not-comparison-to-zero,
436436
no-else-return,
437437
inconsistent-return-statements,
438+
unspecified-encoding,
438439

439440
# Enable the message, report, category or checker with the given id(s). You can
440441
# either give multiple identifier separated by comma (,) or put this option

tests/test_flight.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,3 +949,31 @@ def test_aerodynamic_moments(flight_calisto_custom_wind, flight_time, expected_v
949949
test.M2(t),
950950
test.M3(t),
951951
), f"Assertion error for moment vector at {expected_attr}."
952+
953+
954+
def test_export_pressures(flight_calisto_robust):
955+
"""Tests if the method Flight.export_pressures is working as intended.
956+
957+
Parameters
958+
----------
959+
flight_calisto_robust : Flight
960+
Flight object to be tested. See the conftest.py file for more info
961+
regarding this pytest fixture.
962+
"""
963+
file_name = "pressures.csv"
964+
time_step = 0.5
965+
parachute = flight_calisto_robust.rocket.parachutes[0]
966+
967+
flight_calisto_robust.export_pressures(file_name, time_step)
968+
969+
with open(file_name, "r") as file:
970+
contents = file.read()
971+
972+
expected_data = ""
973+
for t in np.arange(0, flight_calisto_robust.t_final, time_step):
974+
p_cl = parachute.clean_pressure_signal_function(t)
975+
p_ns = parachute.noisy_pressure_signal_function(t)
976+
expected_data += f"{t:f}, {p_cl:.5f}, {p_ns:.5f}\n"
977+
978+
assert contents == expected_data
979+
os.remove(file_name)

0 commit comments

Comments
 (0)