Skip to content

Commit

Permalink
TST: add Entry validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shilorigins committed May 31, 2024
1 parent 6b55df3 commit 040e64a
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions superscore/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import apischema

from superscore.model import (Collection, Parameter, Severity, Snapshot,
Status, Value)
from superscore.model import (Collection, Parameter, Readback, Setpoint,
Severity, Snapshot, Status, Value)


def test_serialize_collection_roundtrip():
Expand Down Expand Up @@ -36,3 +36,56 @@ def test_serialize_snapshot_roundtrip():
assert deserialized.children[2] == v4
assert deserialized.children[1].children[0] == v1
assert deserialized.children[1].children[1] == v2


class TestEntryValidation:
@staticmethod
def test_fixture_validation(linac_backend):
linac_model = linac_backend.get_entry("441ff79f-4948-480e-9646-55a1462a5a70")
assert linac_model.validate()

linac_snapshot = linac_backend.get_entry("06282731-33ea-4270-ba14-098872e627dc")
assert linac_snapshot.validate()

@staticmethod
def test_parameter_readback_validation(linac_backend):
vac_gunb_pv1 = linac_backend.get_entry("8f3ac401-68f8-4def-b65a-3c8116c80ba7")
vac_gunb_pv2 = linac_backend.get_entry("06448272-cd38-4bb4-9b8d-292673a497e9")
vac_gunb_pv1.readback = vac_gunb_pv2
assert vac_gunb_pv1.validate()

vac_gunb_pv2.abs_tolerance = "1"
assert not vac_gunb_pv1.validate()

@staticmethod
def test_setpoint_validation(linac_backend):
vac_li21_readback = linac_backend.get_entry("de66d08e-09c3-4c45-8978-900e51d00248")
vac_li21_setpoint = linac_backend.get_entry("4bffe9a5-f198-41d8-90ab-870d1b5a325b")
assert vac_li21_readback.validate()
assert vac_li21_setpoint.validate()

vac_li21_readback.rel_tolerance = "10%"
assert not vac_li21_setpoint.validate()

@staticmethod
def test_nestable_empty_validation(linac_backend):
linac_model = linac_backend.get_entry("441ff79f-4948-480e-9646-55a1462a5a70")
vac_bsy_col = linac_backend.get_entry("22c2d597-2139-4c02-ac86-27f474728fad")
vac_bsy_col.children = []
assert not linac_model.validate()

@staticmethod
def test_nestable_cycle_validation(linac_backend):
linac_model = linac_backend.get_entry("441ff79f-4948-480e-9646-55a1462a5a70")
bsy_col = linac_backend.get_entry("2506d87a-5980-4470-b29a-63eea183f53d")
vac_bsy_col = linac_backend.get_entry("22c2d597-2139-4c02-ac86-27f474728fad")
vac_bsy_col.children.append(bsy_col)
assert not linac_model.validate()

@staticmethod
def test_collection_reachable_from_snapshot_validation(linac_backend):
linac_snapshot = linac_backend.get_entry("06282731-33ea-4270-ba14-098872e627dc")
bsy_snapshot = linac_backend.get_entry("a62f1386-39de-4d19-9ea4-82f0212169a7")
vac_bsy_col = linac_backend.get_entry("22c2d597-2139-4c02-ac86-27f474728fad")
bsy_snapshot.children.append(vac_bsy_col)
assert not linac_snapshot.validate()

0 comments on commit 040e64a

Please sign in to comment.