Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Tidy up tests #91

Merged
merged 5 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
run: python -m $(ls src | head -1) --version

container:
needs: [lint, dist, test, system-test]
needs: [lint, dist, test]
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:

release:
# upload to PyPI and make a release on every tag
needs: [lint, dist, test, system-test]
needs: [lint, dist, test]
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest
env:
Expand Down
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
20 changes: 10 additions & 10 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 Expand Up @@ -147,9 +147,9 @@ Click the arrows to reveal the files.
.. raw:: html

<details>
<summary><a>bl45p-mo-ioc-02.ibek.ioc.yaml</a></summary>
<summary><a>all.ibek.ioc.yaml</a></summary>

.. include:: ../../../tests/samples/yaml/bl45p-mo-ioc-02.ibek.ioc.yaml
.. include:: ../../../tests/samples/yaml/all.ibek.ioc.yaml
:literal:

.. raw:: html
Expand All @@ -158,7 +158,7 @@ Click the arrows to reveal the files.
<details>
<summary><a>st.cmd</a></summary>

.. include:: ../../../tests/samples/boot_scripts/st.cmd
.. include:: ../../../tests/samples/outputs/all.st.cmd
:literal:

.. raw:: html
Expand Down Expand Up @@ -209,18 +209,18 @@ The Global Schema and example IOC instance schema are below:
.. raw:: html

<details>
<summary><a>ibek.defs.schema.json</a></summary>
<summary><a>ibek.support.schema.json</a></summary>

.. include:: ../../../tests/samples/schemas/ibek.defs.schema.json
.. include:: ../../../tests/samples/schemas/ibek.support.schema.json
:literal:

.. raw:: html

</details>
<details>
<summary><a>pmac.ibek.entities.schema.json</a></summary>
<summary><a>multiple.ibek.ioc.schema.json</a></summary>

.. include:: ../../../tests/samples/schemas/pmac.ibek.entities.schema.json
.. include:: ../../../tests/samples/schemas/multiple.ibek.ioc.schema.json
:literal:

.. raw:: html
Expand Down
1 change: 0 additions & 1 deletion ibek-defs
Submodule ibek-defs deleted from 8772cc
30 changes: 19 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,52 @@

from pytest import fixture
from ruamel.yaml import YAML
from typer.testing import CliRunner

from ibek.__main__ import cli
from ibek.ioc import clear_entity_model_ids, make_entity_models
from ibek.support import Support

runner = CliRunner()

def get_support(samples: Path, yaml_file: str) -> Support:

def run_cli(*args):
result = runner.invoke(cli, [str(x) for x in args])
if result.exception:
raise result.exception
assert result.exit_code == 0, result


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
88 changes: 88 additions & 0 deletions tests/generate_samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

# this script regenerates the files used in tests
# it is useful after making changes to the code that affect the schemas etc.
#
# please bear in mind that this is cheating tests! It requires visual
# verifiction of the files in the samples folders after running.
#

export SAMPLES_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))/samples


# this is so relative schema mode lines work
cd $SAMPLES_DIR
mkdir -p schemas
mkdir -p outputs

set -x
echo making the support yaml schema
ibek ibek-schema schemas/ibek.support.schema.json

echo making an ioc schema using object support yaml
ibek ioc-schema yaml/objects.ibek.support.yaml schemas/objects.ibek.ioc.schema.json

echo making an ioc schema using multiple support yaml files
ibek ioc-schema yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml schemas/multiple.ibek.ioc.schema.json

# echo making ioc based on objects support yaml
ibek build-startup yaml/objects.ibek.ioc.yaml yaml/objects.ibek.support.yaml --out outputs/objects.st.cmd --db-out outputs/objects.make_db.sh

# echo making ioc based on mutiple support yaml
ibek build-startup yaml/all.ibek.ioc.yaml yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --out outputs/all.st.cmd --db-out outputs/all.make_db.sh


# echo making the global ioc schema using all support yaml in ibek-defs
# ibek ioc-schema ./*/*.ibek.support.yaml ${SAMPLES_DIR}/schemas/all.ibek.support.schema.json



# echo making the epics definition schema
# ibek ioc-schema ${DEFS}/_global/epics.ibek.support.yaml $SAMPLES_DIR/schemas/epics.ibek.support.schema.json
# echo making the pmac support module definition schema
# ibek ioc-schema ${DEFS}/pmac/pmac.ibek.support.yaml $SAMPLES_DIR/schemas/pmac.ibek.entities.schema.json
# echo making the asyn support module definition schema
# ibek ioc-schema ${DEFS}/asyn/asyn.ibek.support.yaml $SAMPLES_DIR/schemas/asyn.ibek.entities.schema.json
# echo making a container definition schema
# ibek ioc-schema ${DEFS}/asyn/asyn.ibek.support.yaml ${DEFS}/pmac/pmac.ibek.support.yaml $SAMPLES_DIR/schemas/container.ibek.entities.schema.json
# echo making a schema for bl45p-mo-ioc-04
# ibek ioc-schema ${DEFS}/_global/epics.ibek.support.yaml ${DEFS}/pmac/pmac.ibek.support.yaml $SAMPLES_DIR/schemas/bl45p-mo-ioc-04.ibek.entities.schema.json

# echo making bl45p-mo-ioc-02
# ibek build-startup ${SAMPLES_DIR}/yaml/bl45p-mo-ioc-02.ibek.ioc.yaml ${DEFS}/pmac/pmac.ibek.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/boot_scripts/
# echo making bl45p-mo-ioc-03
# ibek build-startup ${SAMPLES_DIR}/yaml/bl45p-mo-ioc-03.ibek.ioc.yaml ${DEFS}/pmac/pmac.ibek.support.yaml ${DEFS}/asyn/asyn.ibek.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/boot_scripts/stbl45p-mo-ioc-03
# echo making bl45p-mo-ioc-04
# ibek build-startup ${SAMPLES_DIR}/yaml/bl45p-mo-ioc-04.ibek.ioc.yaml ${DEFS}/_global/epics.ibek.support.yaml ${DEFS}/pmac/pmac.ibek.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/boot_scripts/stbl45p-mo-ioc-04
# echo making test-ioc
# ibek build-startup ${SAMPLES_DIR}/example-ibek-config/ioc.yaml ${DEFS}/_global/epics.ibek.support.yaml ${DEFS}/_global/devIocStats.ibek.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/boot_scripts/test.ioc.cmd
# cp /tmp/ioc/make_db.sh ${SAMPLES_DIR}/boot_scripts/test.ioc.make_db.sh

# echo making SR-RF-IOC-08 IOC
# ibek build-startup ${SAMPLES_DIR}/example-srrfioc08/SR-RF-IOC-08.ibek.ioc.yaml ${DEFS}/*/*.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/example-srrfioc08
# cp /tmp/ioc/make_db.sh ${SAMPLES_DIR}/example-srrfioc08

# echo making values_test IOC
# ibek build-startup ${SAMPLES_DIR}/values_test/values.ibek.ioc.yaml ${DEFS}/*/*.support.yaml --out /tmp/ioc/st.cmd --db-out /tmp/ioc/make_db.sh
# cp /tmp/ioc/st.cmd ${SAMPLES_DIR}/values_test

# PYDANTIC_DIR=${SAMPLES_DIR}/pydantic
# cd $PYDANTIC_DIR

# echo making the support yaml schema
# ibek ibek-schema ${PYDANTIC_DIR}/../schemas/ibek.defs.schema.json

# echo making the pydantic test definition schema
# ibek ioc-schema ${PYDANTIC_DIR}/test.ibek.support.yaml $PYDANTIC_DIR/test.ibek.ioc.schema.json

# echo making the pydantic test ioc startup script
# ibek build-startup ${PYDANTIC_DIR}/test.ibek.ioc.yaml ${PYDANTIC_DIR}/test.ibek.support.yaml --out $PYDANTIC_DIR/st.cmd --db-out $PYDANTIC_DIR/make_db.sh




17 changes: 0 additions & 17 deletions tests/samples/boot_scripts/st.cmd

This file was deleted.

22 changes: 0 additions & 22 deletions tests/samples/boot_scripts/stbl45p-mo-ioc-03

This file was deleted.

15 changes: 0 additions & 15 deletions tests/samples/boot_scripts/test.ioc.cmd

This file was deleted.

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

This file was deleted.

5 changes: 0 additions & 5 deletions tests/samples/example-ibek-config/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions tests/samples/example-ibek-config/ioc.db

This file was deleted.

20 changes: 0 additions & 20 deletions tests/samples/example-ibek-config/ioc.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions tests/samples/example-srrfioc08/SR-RF-IOC-08.ibek.ioc.yaml

This file was deleted.

Loading