From 2d841f75d0ad3d4451cf721420a6f1b10262e11b Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 15 May 2024 12:49:24 +0100 Subject: [PATCH] apply Garys PR comments --- src/ibek/globals.py | 5 ++--- tests/conftest.py | 8 +++++--- tests/test_cli.py | 32 ++++++++++++++++---------------- tests/test_error.py | 6 +++--- tests/test_support.py | 2 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/ibek/globals.py b/src/ibek/globals.py index 4d8e268f8..57cdc6608 100644 --- a/src/ibek/globals.py +++ b/src/ibek/globals.py @@ -76,7 +76,6 @@ def IBEK_DEFS(self): def PVI_DEFS(self): """Directory containing pvi device yaml definitions.""" return self._EPICS_ROOT / "pvi-defs" - return self._EPICS_ROOT / "pvi-defs" @property def OPI_OUTPUT(self): @@ -85,7 +84,7 @@ def OPI_OUTPUT(self): @property def EPICS_BASE(self): - """xx""" + """The folder containing the epics base source and binaries""" return self._EPICS_ROOT / "epics-base" @property @@ -95,7 +94,7 @@ def IOC_FOLDER(self): @property def CONFIG_DIR_NAME(self): - """configuration directory name for the IOC""" + """Name of config directory within IOC directory""" return "config" @property diff --git a/tests/conftest.py b/tests/conftest.py index 1770ab303..c806a4f48 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,11 +60,13 @@ def entity_factory(): @fixture -def epics_root(samples: Path, tmp_path: Path, mocker: MockerFixture): +def tmp_epics_root(samples: Path, tmp_path: Path, mocker: MockerFixture): # create an partially populated epics_root structure in a temporary folder epics = tmp_path / "epics" - shutil.copytree(samples / "epics", epics) - Path.mkdir(epics / "opi", exist_ok=True) + epics.mkdir() + shutil.copytree(samples / "epics" / "pvi-defs", epics / "pvi-defs") + shutil.copytree(samples / "epics" / "support", epics / "support") + Path.mkdir(epics / "opi") Path.mkdir(epics / "epics-base") Path.mkdir(epics / "ioc/config", parents=True) Path.mkdir(epics / "ibek-defs") diff --git a/tests/test_cli.py b/tests/test_cli.py index afe346161..4a723978b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -80,7 +80,7 @@ def test_motor_sim_schema(tmp_path: Path, samples: Path): assert expected == actual -def test_build_runtime_motorSim(epics_root: Path, samples: Path): +def test_build_runtime_motorSim(tmp_epics_root: Path, samples: Path): """ build an ioc runtime script from an IOC instance entity file and multiple support module definition files @@ -96,27 +96,27 @@ def test_build_runtime_motorSim(epics_root: Path, samples: Path): generate(ioc_yaml, [support_yaml1, support_yaml2]) example_boot = (expected_outputs / "st.cmd").read_text() - actual_boot = (epics_root / "runtime" / "st.cmd").read_text() + actual_boot = (tmp_epics_root / "runtime" / "st.cmd").read_text() assert example_boot == actual_boot example_db = (expected_outputs / "ioc.subst").read_text() - actual_db = (epics_root / "runtime" / "ioc.subst").read_text() + actual_db = (tmp_epics_root / "runtime" / "ioc.subst").read_text() assert example_db == actual_db example_index = (expected_outputs / "index.bob").read_text() - actual_index = (epics_root / "opi" / "index.bob").read_text() + actual_index = (tmp_epics_root / "opi" / "index.bob").read_text() assert example_index == actual_index example_bob = (expected_outputs / "simple.pvi.bob").read_text() - actual_bob = (epics_root / "opi" / "simple.pvi.bob").read_text() + actual_bob = (tmp_epics_root / "opi" / "simple.pvi.bob").read_text() assert example_bob == actual_bob example_template = (expected_outputs / "simple.pvi.template").read_text() - actual_template = (epics_root / "runtime" / "simple.pvi.template").read_text() + actual_template = (tmp_epics_root / "runtime" / "simple.pvi.template").read_text() assert example_template == actual_template -def test_build_utils_features(epics_root: Path, samples: Path): +def test_build_utils_features(tmp_epics_root: Path, samples: Path): """ build an ioc runtime script to verify utils features """ @@ -126,11 +126,11 @@ def test_build_utils_features(epics_root: Path, samples: Path): run_cli("runtime", "generate", ioc_yaml, support_yaml) example_boot = (samples / "outputs" / "utils" / "st.cmd").read_text() - actual_boot = (epics_root / "runtime" / "st.cmd").read_text() + actual_boot = (tmp_epics_root / "runtime" / "st.cmd").read_text() assert example_boot == actual_boot example_db = (samples / "outputs" / "utils" / "ioc.subst").read_text() - actual_db = (epics_root / "runtime" / "ioc.subst").read_text() + actual_db = (tmp_epics_root / "runtime" / "ioc.subst").read_text() assert example_db == actual_db @@ -147,7 +147,7 @@ def test_generate_links_ibek(samples: Path, mocker: MockerFixture): ) -def test_ipac(epics_root: Path, samples: Path): +def test_ipac(tmp_epics_root: Path, samples: Path): """ Tests that an id argument can include another argument in its default value """ @@ -164,11 +164,11 @@ def test_ipac(epics_root: Path, samples: Path): generate(ioc_yaml, [support_yaml1, support_yaml2]) example_boot = (expected_outputs / "st.cmd").read_text() - actual_boot = (epics_root / "runtime" / "st.cmd").read_text() + actual_boot = (tmp_epics_root / "runtime" / "st.cmd").read_text() assert example_boot == actual_boot -def test_gauges(epics_root: Path, samples: Path): +def test_gauges(tmp_epics_root: Path, samples: Path): """ Tests that an id argument can include another argument in its default value """ @@ -180,11 +180,11 @@ def test_gauges(epics_root: Path, samples: Path): generate(ioc_yaml, [support_yaml1, support_yaml2]) example_boot = (expected_outputs / "st.cmd").read_text() - actual_boot = (epics_root / "runtime" / "st.cmd").read_text() + actual_boot = (tmp_epics_root / "runtime" / "st.cmd").read_text() assert example_boot == actual_boot -def test_quadem(epics_root: Path, samples: Path): +def test_quadem(tmp_epics_root: Path, samples: Path): """ Tests the use of CollectionDefinitions in an IOC instance this example uses the tetramm beam position monitor module @@ -197,9 +197,9 @@ def test_quadem(epics_root: Path, samples: Path): generate(ioc_yaml, [support_yaml1, support_yaml2]) example_boot = (expected_outputs / "st.cmd").read_text() - actual_boot = (epics_root / "runtime" / "st.cmd").read_text() + actual_boot = (tmp_epics_root / "runtime" / "st.cmd").read_text() assert example_boot == actual_boot example_db = (samples / "outputs" / "quadem" / "ioc.subst").read_text() - actual_db = (epics_root / "runtime" / "ioc.subst").read_text() + actual_db = (tmp_epics_root / "runtime" / "ioc.subst").read_text() assert example_db == actual_db diff --git a/tests/test_error.py b/tests/test_error.py index 8f1481302..d616bb1ad 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -13,7 +13,7 @@ from tests.conftest import run_cli -def test_counter_reuse(epics_root: Path, samples: Path): +def test_counter_reuse(tmp_epics_root: Path, samples: Path): """ Check you cannot redefine a counter with the same name and different params """ @@ -30,7 +30,7 @@ def test_counter_reuse(epics_root: Path, samples: Path): ) -def test_counter_overuse(epics_root: Path, samples: Path): +def test_counter_overuse(tmp_epics_root: Path, samples: Path): """ Check that counter limits are enforced """ @@ -60,7 +60,7 @@ def test_bad_ref(samples: Path): assert "object controllerOnePort_BAD_REF not found" in str(ctx.value) -def test_bad_db(epics_root: Path, samples: Path): +def test_bad_db(tmp_epics_root: Path, samples: Path): """ Check bad database args are caught """ diff --git a/tests/test_support.py b/tests/test_support.py index 991606650..6a7b258b8 100644 --- a/tests/test_support.py +++ b/tests/test_support.py @@ -32,7 +32,7 @@ def test_symlink_pvi(tmp_path: Path, samples: Path): # note this must refer to epics_root to patch where check_deps looks for # the support files -def test_check_dependencies(epics_root: Path): +def test_check_dependencies(tmp_epics_root: Path): # Check Passes vs test data check_deps(["ADSimDetector"])