Skip to content

Commit

Permalink
apply Garys PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed May 15, 2024
1 parent 49ee13b commit 2d841f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/ibek/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
32 changes: 16 additions & 16 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"""
Expand All @@ -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


Expand All @@ -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
"""
Expand All @@ -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
"""
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions tests/test_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down

0 comments on commit 2d841f7

Please sign in to comment.