Commit 08350cb6 authored by Jan Kiene's avatar Jan Kiene
Browse files

adapt tests to create configs with script

parent 10ded0d6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#

from pathlib import PurePath
from itertools import cycle

""" Set up paths """
TESTS_DIR = PurePath(__file__).parent
@@ -227,5 +228,7 @@ INPUT_EXPERIMENT_NAMES = [
    "P800-8",
    "P800-9",
]
__LABS = cycle("abcd")
LAB_IDS_FOR_EXPERIMENTS = [next(__LABS) for e in INPUT_EXPERIMENT_NAMES]

CREATE_CATEGORIES_TESTS = ["P800-2"]
+14 −20
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ from tests.constants import (
    FORMAT_TO_METADATA_FILES,
    INPUT_EXPERIMENT_NAMES,
    NCHAN_TO_FILE,
    LAB_IDS_FOR_EXPERIMENTS,
    TESTS_DIR,
)
from experiments import create_experiment_config, create_items_p800
@@ -59,7 +60,7 @@ class Arguments:
        self.debug = True


def setup_input_files_for_config(config, category=1):
def setup_input_files_for_config(config):
    input_path = Path(config.input_path).resolve().absolute()
    input_fmt = config.input["fmt"]

@@ -104,34 +105,27 @@ def setup_input_files_for_config(config, category=1):
        write(bg_noise_path, noise)


@pytest.mark.parametrize("exp_name", INPUT_EXPERIMENT_NAMES)
def test_generate_test_items(exp_name):
    cfg_dir = Path(TESTS_DIR).joinpath(EXPERIMENTS_DIR)
    exp_path = Path(cfg_dir).joinpath(Path(exp_name)).resolve().absolute()
    if not (cfg := exp_path.joinpath(f"config/{exp_name}.yml")).exists():
        # for the P800 tests - they have different configs per category
        cfg = exp_path.joinpath(f"config/{exp_name}-cat1.yml")
    args = Arguments(cfg)
@pytest.mark.parametrize("exp_lab_pair", zip(INPUT_EXPERIMENT_NAMES, LAB_IDS_FOR_EXPERIMENTS))
def test_generate_test_items(exp_lab_pair):
    exp_name, lab_id = exp_lab_pair
    cfgs = sorted(create_experiment_config.create_experiment_setup(exp_name, lab_id))
    cfg = cfgs[0]

    args = Arguments(cfg)
    config = TestConfig(cfg)

    setup_input_files_for_config(config)

    generate_test(args)


@pytest.mark.parametrize("exp_name", CREATE_CATEGORIES_TESTS)
def test_categories(exp_name):
    for cat in range(1, 7):
        cfg_dir = Path(TESTS_DIR).joinpath(EXPERIMENTS_DIR)
        cfg = Path(cfg_dir).joinpath(Path(exp_name)).resolve().absolute()
        cfg = cfg.joinpath(f"config/{exp_name}-cat{cat}.yml")

@pytest.mark.parametrize("lab_id", ["a", "b", "c", "d"])
def test_categories(exp_name, lab_id):
    cfgs = create_experiment_config.create_experiment_setup(exp_name, lab_id)
    for cfg in cfgs:
        config = TestConfig(cfg)
        setup_input_files_for_config(config)

        setup_input_files_for_config(config, cat)

    create_items_p800.create_items(exp_name)
    create_items_p800.create_items(exp_name, lab_id)


@pytest.mark.parametrize("exp_name", [f"P800-{i}" for i in range(1, 10)])