Skip to content

Commit

Permalink
Moved pytest fixture that returns test data to conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bourque committed Sep 3, 2024
1 parent 15af12b commit 393db0b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
22 changes: 22 additions & 0 deletions imap_processing/tests/idex/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pathlib import Path

import pytest
import xarray as xr

from imap_processing import imap_module_directory
from imap_processing.idex.l1.idex_l1 import PacketParser


@pytest.fixture()
def decom_test_data() -> xr.Dataset:
"""Return a ``xarray`` dataset containing test data.
Returns
-------
dataset : xarray.Dataset
A ``xarray`` dataset containing the test data
"""
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts"
)
return PacketParser(test_file, "001").data
19 changes: 0 additions & 19 deletions imap_processing/tests/idex/test_idex_l0.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
"""Tests the decommutation process for IDEX CCSDS Packets."""

from pathlib import Path

import numpy as np
import pytest
import xarray as xr

from imap_processing import imap_module_directory
from imap_processing.idex.l1.idex_l1 import PacketParser


@pytest.fixture(scope="session")
def decom_test_data() -> xr.Dataset:
"""Return a ``xarray`` dataset containing test data.
Returns
-------
dataset : xarray.Dataset
A ``xarray`` dataset containing the test data
"""
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts"
)
return PacketParser(test_file, "001").data


def test_idex_decom_length(decom_test_data: xr.Dataset):
Expand Down
18 changes: 0 additions & 18 deletions imap_processing/tests/idex/test_idex_l1.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
"""Tests the L1 processing for decommutated IDEX data"""

from pathlib import Path

import numpy as np
import pytest
import xarray as xr
from cdflib.xarray.xarray_to_cdf import ISTPError

from imap_processing import imap_module_directory
from imap_processing.cdf.utils import load_cdf, write_cdf
from imap_processing.idex.l1.idex_l1 import PacketParser


@pytest.fixture()
def decom_test_data() -> xr.Dataset:
"""Return a ``xarray`` dataset containing test data.
Returns
-------
dataset : xarray.Dataset
A ``xarray`` dataset containing the test data
"""
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_v001.pkts"
)
return PacketParser(test_file, "v001").data


def test_idex_cdf_file(decom_test_data: xr.Dataset):
Expand Down

0 comments on commit 393db0b

Please sign in to comment.