Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Move test structure to a single test directory #308

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion imap_processing/idex/idex_packet_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PacketParser:
--------
>>> # Print out the data in a L0 file
>>> from imap_processing.idex.idex_packet_parser import PacketParser
>>> l0_file = "imap_processing/idex/tests/imap_idex_l0_20230725_v01-00.pkts"
>>> l0_file = "imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts"
>>> l1_data = PacketParser(l0_file)
>>> l1_data.write_l1_cdf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def decom_test_data() -> list:
"""

packet_file = Path(
f"{imap_module_directory}/codice/tests/data/"
f"{imap_module_directory}/tests/codice/data/"
f"raw_ccsds_20230822_122700Z_idle.bin"
)
Path(f"{imap_module_directory}/codice/packet_definitions/P_COD_NHK.xml")
Expand All @@ -51,7 +51,7 @@ def validation_data() -> pd.core.frame.DataFrame:

# Read in the CSV file
validation_file = Path(
f"{imap_module_directory}/codice/tests/data/"
f"{imap_module_directory}/tests/codice/data/"
f"idle_export_raw.COD_NHK_20230822_122700.csv"
)
validation_data = pd.read_csv(validation_file, index_col="SHCOARSE")
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_eu_hk_data(
l1a_hk_ds = create_dataset(decom_test_data)
eu_hk_data = convert_raw_to_eu(
l1a_hk_ds,
imap_module_directory / "codice/tests/data/eu_unit_lookup_table.csv",
imap_module_directory / "tests/codice/data/eu_unit_lookup_table.csv",
"P_COD_NHK",
)
first_data = decom_test_data[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def l0_test_data() -> list:
"""

packet_file = Path(
f"{imap_module_directory}/codice/tests/data/"
f"{imap_module_directory}/tests/codice/data/"
f"raw_ccsds_20230822_122700Z_idle.bin"
)
packets = decom_packets(packet_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@pytest.fixture(scope="session")
def decom_nhk_data():
"""Read test housekeeping data from test folder"""
test_folder_path = "hi/tests/l0_test_data"
test_folder_path = "tests/hi/l0_test_data"
packet_file = imap_module_directory / f"{test_folder_path}/20231030_H45_APP_NHK.bin"
packet_def_file = imap_module_directory / "hi/packet_definitions/H45_APP_NHK.xml"
return decom_packets(packet_file, packet_def_file)
Expand All @@ -17,7 +17,7 @@ def decom_nhk_data():
@pytest.fixture(scope="session")
def nhk_validation_data():
"""Read in validation data from the CSV file"""
test_data_path = imap_module_directory / "hi/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/hi/l0_validation_data"
raw_validation_data = pd.read_csv(
test_data_path / "20231030_H45_APP_NHK.csv",
index_col="CCSDS_MET",
Expand All @@ -28,7 +28,7 @@ def nhk_validation_data():
@pytest.fixture(scope="session")
def decom_sci_de_data():
"""Read science direct event data from test folder"""
test_folder_path = "hi/tests/l0_test_data"
test_folder_path = "tests/hi/l0_test_data"
packet_file = imap_module_directory / f"{test_folder_path}/20231030_H45_SCI_DE.bin"
packet_def_file = imap_module_directory / "hi/packet_definitions/H45_SCI_DE.xml"
return decom_packets(packet_file, packet_def_file)
Expand All @@ -37,7 +37,7 @@ def decom_sci_de_data():
@pytest.fixture(scope="session")
def decom_sci_cnt_data():
"""Read science count data from test folder"""
test_folder_path = "hi/tests/l0_test_data"
test_folder_path = "tests/hi/l0_test_data"
packet_file = imap_module_directory / f"{test_folder_path}/20231030_H45_SCI_CNT.bin"
packet_def_file = imap_module_directory / "hi/packet_definitions/H45_SCI_CNT.xml"
return decom_packets(packet_file, packet_def_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def decom_test_data():
"""Read test data from file"""
packet_file = (
"imap_processing/hit/tests/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts"
"imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts"
)
xtce = "imap_processing/hit/packet_definitions/P_HIT_HSKP.xml"
data_packet_list = hit_l1a_decom.decom_hit_packets(packet_file, xtce)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def binary_packet_path(tmp_path):
"""
packet_path = (
imap_module_directory
/ "ialirt"
/ "tests"
/ "ialirt"
/ "test_data"
/ "l0"
/ "IALiRT Raw Packet Telemetry.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@pytest.fixture(scope="session")
def decom_test_data():
return PacketParser("imap_processing/idex/tests/imap_idex_l0_20230725_v01-00.pkts")
return PacketParser("imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts")


def test_idex_decom_length(decom_test_data):
Expand All @@ -23,6 +23,6 @@ def test_idex_decom_event_num(decom_test_data):
def test_idex_tof_high_data(decom_test_data):
# Verify that a sample of the data is correct
# impact_14_tof_high_data.txt has been verified correct by the IDEX team
with open("imap_processing/idex/tests/impact_14_tof_high_data.txt") as f:
with open("imap_processing/tests/idex/impact_14_tof_high_data.txt") as f:
data = np.array([int(line.rstrip("\n")) for line in f])
assert (decom_test_data.data["TOF_High"][13].data == data).all()
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@pytest.fixture()
def decom_test_data():
return PacketParser("imap_processing/idex/tests/imap_idex_l0_20230725_v01-00.pkts")
return PacketParser("imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts")


@pytest.fixture()
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_descriptor_in_file_name(decom_test_data, temp_path):
def test_idex_tof_high_data_from_cdf(decom_test_data, temp_path):
# Verify that a sample of the data is correct inside the CDF file
# impact_14_tof_high_data.txt has been verified correct by the IDEX team
with open("imap_processing/idex/tests/impact_14_tof_high_data.txt") as f:
with open("imap_processing/tests/idex/impact_14_tof_high_data.txt") as f:
data = np.array([int(line.rstrip()) for line in f])

file_name = write_cdf(decom_test_data.data, description="", directory=temp_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@pytest.fixture(scope="session")
def decom_test_data():
"""Read test data from test folder"""
test_folder_path = "swe/tests/l0_data"
test_folder_path = "tests/swe/l0_data"
packet_files = list(imap_module_directory.glob(f"{test_folder_path}/*.bin"))

data_list = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@pytest.fixture(scope="session")
def decom_test_data():
"""Read test data from file"""
test_folder_path = imap_module_directory / "swe/tests/l0_data"
test_folder_path = imap_module_directory / "tests/swe/l0_data"
packet_1_file = test_folder_path / "20230927100425_SWE_CEM_RAW_packet.bin"
packet_2_file = test_folder_path / "20230927100426_SWE_CEM_RAW_packet.bin"
first_data = decom_swe.decom_packets(packet_1_file)
Expand All @@ -26,7 +26,7 @@ def test_number_of_packets(decom_test_data):
def test_swe_raw_cem_data(decom_test_data):
"""This test and validate raw data of SWE raw CEM data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
raw_validation_data = pd.read_csv(
test_data_path / "data_raw.SWE_CEM_RAW_20230927_094839.csv",
index_col="SHCOARSE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@pytest.fixture(scope="session")
def decom_test_data():
"""Read test data from file"""
test_folder_path = "swe/tests/l0_data"
test_folder_path = "tests/swe/l0_data"
event_file_list = list(
imap_module_directory.glob(f"{test_folder_path}/*SWE_EVTMSG_packet.bin")
)
Expand All @@ -28,7 +28,7 @@ def test_number_of_packets(decom_test_data):
def test_swe_event_msg_data(decom_test_data):
"""This test and validate raw data of SWE event message data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"

raw_validation_data = pd.read_csv(
test_data_path / "idle_export_raw.SWE_EVTMSG_20231004_140149.csv",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
def decom_test_data():
"""Read test data from file"""
packet_1_file = (
imap_module_directory / "swe/tests/l0_data/20230927100248_SWE_HK_packet.bin"
imap_module_directory / "tests/swe/l0_data/20230927100248_SWE_HK_packet.bin"
)
packet_2_file = (
imap_module_directory / "swe/tests/l0_data/20230927100412_SWE_HK_packet.bin"
imap_module_directory / "tests/swe/l0_data/20230927100412_SWE_HK_packet.bin"
)
first_data = decom_swe.decom_packets(packet_1_file)
second_data = decom_swe.decom_packets(packet_2_file)
Expand All @@ -29,7 +29,7 @@ def test_number_of_packets(decom_test_data):
def test_swe_raw_housekeeping_data(decom_test_data):
"""This test and validate raw and derived data of SWE housekeeping data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
raw_validation_data = pd.read_csv(
test_data_path / "data_raw.SWE_APP_HK_20230927_094839.csv",
index_col="SHCOARSE",
Expand All @@ -51,7 +51,7 @@ def test_swe_raw_housekeeping_data(decom_test_data):
def test_swe_derived_housekeeping_data(decom_test_data):
"""This test and validate derived data of SWE housekeeping data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
derived_validation_data = pd.read_csv(
test_data_path / "data_derived.SWE_APP_HK_20230927_094839.csv",
index_col="SHCOARSE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def decom_test_data():
# reorder to match the order of spin in the data
packet_files = [
imap_module_directory
/ "swe/tests/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
]
data_list = []
for packet_file in packet_files:
Expand All @@ -50,7 +50,7 @@ def test_decompress_algorithm():
def test_swe_raw_science_data(decom_test_data):
"""This test and validate raw and derived data of SWE science data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
raw_validation_data = pd.read_csv(
test_data_path / "idle_export_raw.SWE_SCIENCE_20230927_172708.csv",
index_col="SHCOARSE",
Expand All @@ -74,7 +74,7 @@ def test_swe_raw_science_data(decom_test_data):
def test_swe_derived_science_data(decom_test_data):
"""This test and validate raw and derived data of SWE science data."""
# read validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
derived_validation_data = pd.read_csv(
test_data_path / "idle_export_eu.SWE_SCIENCE_20230927_172708.csv",
index_col="SHCOARSE",
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_swe_science_algorithm(decom_test_data):

def test_decompress_counts(decom_test_data):
"""Test decompress counts."""
test_data_path = imap_module_directory / "swe/tests/decompressed"
test_data_path = imap_module_directory / "tests/swe/decompressed"
filepaths = [
"20230927173253_1st_quarter_decompressed.csv",
"20230927173308_2nd_quarter_decompressed.csv",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@pytest.fixture(scope="session")
def decom_test_data():
"""Read test data from test folder"""
test_folder_path = "swe/tests/l0_data"
test_folder_path = "tests/swe/l0_data"
packet_files = list(imap_module_directory.glob(f"{test_folder_path}/*.bin"))

data_list = []
Expand All @@ -40,13 +40,13 @@ def l1a_test_data():
# moved packet 1 to bottom to show data in order.
packet_files = [
imap_module_directory
/ "swe/tests/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
]
data = []
for packet_file in packet_files:
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_swe_l1b(decom_test_data):
)

# read science validation data
test_data_path = imap_module_directory / "swe/tests/l0_validation_data"
test_data_path = imap_module_directory / "tests/swe/l0_validation_data"
eu_validation_data = pd.read_csv(
test_data_path / "idle_export_eu.SWE_SCIENCE_20230927_172708.csv",
index_col="SHCOARSE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def l1a_test_data():
# moved packet 1 to bottom to show data in order.
packet_files = [
imap_module_directory
/ "swe/tests/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173253_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173308_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173323_SWE_SCIENCE_packet.bin",
imap_module_directory
/ "swe/tests/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
/ "tests/swe/l0_data/20230927173238_SWE_SCIENCE_packet.bin",
]
data = []
for packet_file in packet_files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def ccsds_path():
"""Returns the ccsds directory."""
return (
Path(sys.modules[__name__.split(".")[0]].__file__).parent
/ "ultra"
/ "tests"
/ "ultra"
/ "test_data"
/ "l0"
/ "Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.CCSDS"
Expand Down Expand Up @@ -60,8 +60,8 @@ def xtce_image_rates_test_path():
)
return (
Path(sys.modules[__name__.split(".")[0]].__file__).parent
/ "ultra"
/ "tests"
/ "ultra"
/ "test_data"
/ "l0"
/ filename
Expand All @@ -77,8 +77,8 @@ def xtce_aux_test_path():
)
return (
Path(sys.modules[__name__.split(".")[0]].__file__).parent
/ "ultra"
/ "tests"
/ "ultra"
/ "test_data"
/ "l0"
/ filename
Expand Down