Skip to content

Commit

Permalink
tests tidy completed
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Sep 8, 2023
1 parent 4a33908 commit c9359c5
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 1,167 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "ibek-defs"]
path = ibek-defs
url = https://github.com/epics-containers/ibek-defs.git
6 changes: 3 additions & 3 deletions docs/developer/explanations/entities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Each Definition describes a class of Entity by providing:
the above arguments


Expand below for the example pmac **support module definition file**:
Expand below for the example **support module definition file**:

.. raw:: html

<details>
<summary><a>pmac.ibek.support.yaml</a></summary>
<summary><a>objects.ibek.support.yaml</a></summary>

.. include:: ../../../ibek-defs/pmac/pmac.ibek.support.yaml
.. include:: ../../../tests/samples/yaml/objects.ibek.support.yaml
:literal:

.. raw:: html
Expand Down
1 change: 0 additions & 1 deletion ibek-defs
Submodule ibek-defs deleted from 8772cc
19 changes: 8 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,36 @@ def run_cli(*args):
assert result.exit_code == 0, result


def get_support(samples: Path, yaml_file: str) -> Support:
def get_support(yaml_file: str) -> Support:
"""
Get a support object from the sample YAML directory
"""
# load from file
d = YAML(typ="safe").load(samples / f"{yaml_file}")
d = YAML(typ="safe").load(yaml_file)
# create a support object from that dict
support = Support(**d)
return support


@fixture
def ibek_defs():
return Path(__file__).parent.parent / "ibek-defs"


@fixture
def samples():
return Path(__file__).parent / "samples"


@fixture
def pmac_support(ibek_defs):
return get_support(ibek_defs / "pmac", "pmac.ibek.support.yaml")
def yaml_defs(samples):
return samples / "yaml"


@fixture
def pmac_classes(pmac_support):
def objects_classes(yaml_defs):
# clear the entity classes to make sure there's nothing left
clear_entity_model_ids()

objects_support = get_support(yaml_defs / "objects.ibek.support.yaml")

# make entity subclasses for everything defined in it
namespace = make_entity_models(pmac_support)
namespace = make_entity_models(objects_support)

# return the namespace so that callers have access to all of the
# generated dataclasses
Expand Down
7 changes: 5 additions & 2 deletions tests/samples/outputs/all.st.cmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# EPICS IOC Startup Script generated by https://github.com/epics-containers/ibek

cd "/repos/epics/ioc"

epicsEnvSet REF_OBJECT_NAME Ref1

dbLoadDatabase dbd/ioc.dbd
ioc_registerRecordDeviceDriver pdbbase


# testValues TestValue
testValues test_value:Ref1.127.0.0.1
# TestValues testValue
TestValues Ref1.127.0.0.1

# testPreInit identifier TestValue
testPreInit A Consumer test_value:
Expand Down
2 changes: 2 additions & 0 deletions tests/samples/outputs/objects.make_db.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/bin/bash
msi -I${EPICS_DB_INCLUDE_PATH} -M"name=Consumer of another port, ip=10.0.0.2, value=AsynPort2.10.0.0.2" "test.db"
msi -I${EPICS_DB_INCLUDE_PATH} -M"name=Another Consumer of the 2nd port, ip=10.0.0.2, value=AsynPort2.10.0.0.2" "test.db"
16 changes: 10 additions & 6 deletions tests/samples/outputs/objects.st.cmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# EPICS IOC Startup Script generated by https://github.com/epics-containers/ibek

cd "/repos/epics/ioc"

epicsEnvSet REF_OBJECT_NAME AsynPort1
epicsEnvSet REF_OBJECT_NAME AsynPort2

dbLoadDatabase dbd/ioc.dbd
ioc_registerRecordDeviceDriver pdbbase


# testValues TestValue
testValues test_value:AsynPort1.127.0.0.1
testValues test_value:AsynPort2.10.0.0.2
# TestValues testValue
TestValues AsynPort1.127.0.0.1
TestValues AsynPort2.10.0.0.2

# exampleTestFunction AsynPortIP Name Port Value
exampleTestFunction IP:10.0.0.2 name:'Consumer of another port' port:'AsynPort2' Value:AsynPort2.10.0.0.2
exampleTestFunction IP:10.0.0.2 name:'Another Consumer of the 2nd port' port:'AsynPort2' Value:AsynPort2.10.0.0.2
# ExampleTestFunction asynPortIP name port value
ExampleTestFunction 10.0.0.2 Consumer of another port AsynPort2 AsynPort2.10.0.0.2
ExampleTestFunction 10.0.0.2 Another Consumer of the 2nd port AsynPort2 AsynPort2.10.0.0.2

dbLoadRecords /tmp/ioc.db
iocInit
Expand Down
15 changes: 0 additions & 15 deletions tests/samples/outputs/test.ioc.cmd

This file was deleted.

2 changes: 0 additions & 2 deletions tests/samples/outputs/test.ioc.make_db.sh

This file was deleted.

9 changes: 9 additions & 0 deletions tests/samples/yaml/all.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ entities:
- type: module.AllObject
name: A Consumer
my_object: Ref1

- type: object_module.ConsumerTwo
name: Disabled Consumer
PORT: Ref1
entity_enabled: false

- type: object_module.RefObject
name: Disabled RefObject
entity_enabled: false
25 changes: 18 additions & 7 deletions tests/samples/yaml/objects.ibek.support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ defs:
value: "{{ name }}.{{ IP }}"
description: test jinja render of arg values

env_vars:
- name: REF_OBJECT_NAME
value: "{{ name }}"

pre_init:
- type: function
name: testValues
name: TestValues
args:
TestValue: test_value:{{ test_value }}
testValue: "{{ test_value }}"

- name: Consumer
description: |
Expand Down Expand Up @@ -56,9 +60,16 @@ defs:

pre_init:
- type: function
name: exampleTestFunction
name: ExampleTestFunction
args:
asynPortIP: "{{ PORT.IP }}"
name: "{{ name }}"
port: "{{ PORT }}" # defaults to the id of PORT, i.e. PORT.name
value: "{{ PORT.test_value }}"

databases:
- file: test.db
args:
AsynPortIP: IP:{{ PORT.IP }}
Name: name:'{{ name }}'
Port: port:'{{ PORT }}' # defaults to the id of PORT, i.e. PORT.name
Value: Value:{{ PORT.test_value }}
name:
ip: "{{ PORT.IP }}"
value: "{{ PORT.test_value }}"
Loading

0 comments on commit c9359c5

Please # to comment.