Skip to content

Commit

Permalink
TST: Add tests for FlightDataImporter class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Nov 26, 2023
1 parent 4b066d3 commit 3e4bb81
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions rocketpy/simulation/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .flight import Flight
from .flight_data_importer import FlightDataImporter
50 changes: 50 additions & 0 deletions tests/test_flight_data_importer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Tests the FlightDataImporter class from rocketpy.simulation module.
"""
import numpy as np

from rocketpy.simulation import FlightDataImporter


def test_flight_importer_bella_lui():
"""Tests the class using the Bella Lui flight data."""
columns_map = {"time_aprox_(s)": "time", "z_(m)": "altitude", "v_(m/s)": "vz"}
path = "tests/fixtures/acceptance/EPFL_Bella_Lui/bella_lui_flight_data_filtered.csv"

fd = FlightDataImporter(
name="Bella Lui, EPFL Rocket Team, 2020",
filepath=path,
columns_map=columns_map,
units=None,
interpolation="linear",
extrapolation="zero",
separator=",",
encoding="utf-8",
)

assert fd.name == "Bella Lui, EPFL Rocket Team, 2020"
assert "time" in fd.columns, "Can't find 'time' column in fd.columns"
assert "altitude" in fd.columns, "Can't find 'altitude' column in fd.columns"
assert "vz" in fd.columns, "Can't find 'vz' column in fd.columns"
assert np.isclose(fd.altitude(0), 0.201, atol=1e-4)
assert np.isclose(fd.vz(0), 5.028, atol=1e-4)


def test_flight_importer_ndrt():
"""Tests the class using the NDRT 2020 flight data."""
columns_map = {
"Time_(s)": "time",
"Altitude_(Ft-AGL)": "altitude",
}
units = {"Altitude_(Ft-AGL)": "ft"}
path = "tests/fixtures/acceptance/NDRT_2020/ndrt_2020_flight_data.csv"

fd = FlightDataImporter(
name="NDRT Rocket team, 2020",
filepath=path,
columns_map=columns_map,
units=units,
)
assert fd.name == "name"
assert "time" in fd.columns, "Can't find 'time' column in fd.columns"
assert "altitude" in fd.columns, "Can't find 'altitude' column in fd.columns"
assert np.isclose(fd.altitude(0), 0)

0 comments on commit 3e4bb81

Please sign in to comment.