Skip to content

Commit

Permalink
preprocess: test
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristosT committed Jan 16, 2025
1 parent 985a03d commit b9b798f
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
Dexelas_Arguments,
HexrdPPScript_Arguments,
)
import pytest
from pathlib import Path


# FIXME: this is not the appropriate file to test the preprocess scrips since it
# is missing metadata. Until we add a file we just test that validate_arguments()
# works as expected
@pytest.fixture
def eiger_examples_path(example_repo_path: Path) -> Path:
return Path(example_repo_path) / 'eiger'


@pytest.fixture
def ceria_examples_path(eiger_examples_path: Path) -> Path:
return eiger_examples_path / 'first_ceria' / 'ff_000_data_000001.h5'


# test load/safe with defaults
Expand All @@ -21,13 +36,17 @@ def test_save_load_defaults_dexelas():


# test load/safe with modified parameters
def test_save_load_eiger():
def test_save_load_eiger(ceria_examples_path):
eargs = Eiger_Arguments()
eargs.base_dir = "/data"
eargs.num_frames = 1
buffer = eargs.dump_config()
args = HexrdPPScript_Arguments.load_from_config(buffer)
assert eargs == args
with pytest.raises(
RuntimeError
): # required argument 'absolute_path' is missing
args.validate_arguments()
args.absolute_path = str(ceria_examples_path)
args.validate_arguments()


def test_save_load_dexelas():
Expand All @@ -38,3 +57,5 @@ def test_save_load_dexelas():
buffer = eargs.dump_config()
args = HexrdPPScript_Arguments.load_from_config(buffer)
assert eargs == args
with pytest.raises(RuntimeError): # many required arguments are missing
args.validate_arguments()

0 comments on commit b9b798f

Please sign in to comment.