-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from BCDA-APS/unit-tests-synApps
add unit tests for synApps support
- Loading branch information
Showing
8 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import time | ||
|
||
from ..calcout import setup_incrementer_calcout | ||
from ..calcout import CalcoutRecord | ||
from ..calcout import UserCalcoutDevice | ||
|
||
|
||
IOC = "gp:" | ||
|
||
|
||
def test_read(): | ||
calcout = CalcoutRecord(f"{IOC}userCalcOut10", name="sseq") | ||
assert calcout is not None | ||
calcout.wait_for_connection() | ||
|
||
assert len(calcout.read_attrs) == 12 | ||
assert len(calcout.configuration_attrs) == 52 | ||
assert len(calcout._summary().splitlines()) == 173 | ||
|
||
|
||
def test_calcout_reset(): | ||
user = UserCalcoutDevice(IOC, name="user") | ||
user.wait_for_connection() | ||
user.enable.put("Enable") | ||
assert len(user.read()) == 500 | ||
|
||
calcout = user.calcout10 | ||
assert isinstance(calcout, CalcoutRecord) | ||
calcout.enable.put("E") # Note: only "E" | ||
|
||
setup_incrementer_calcout(calcout) | ||
time.sleep(0.2) | ||
assert calcout.description.get() == "incrementer" | ||
assert calcout.calculation.get() == "(A+1) % B" | ||
v1 = calcout.calculated_value.get() | ||
time.sleep(0.2) | ||
assert v1 < calcout.calculated_value.get() | ||
|
||
calcout.reset() | ||
assert calcout.description.get() == calcout.prefix | ||
assert calcout.calculation.get() == "0" | ||
v1 = calcout.calculated_value.get() | ||
time.sleep(0.2) | ||
assert v1 == calcout.calculated_value.get() | ||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2022, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pytest | ||
|
||
from ..iocstats import IocStatsDevice | ||
|
||
|
||
IOC = "gp:" | ||
|
||
|
||
def test_read(): | ||
gp_info = IocStatsDevice(IOC, name="gp_info") | ||
gp_info.wait_for_connection() | ||
assert gp_info.connected | ||
|
||
assert len(gp_info.read_attrs) == 19 | ||
assert len(gp_info.configuration_attrs) == 8 | ||
assert len(gp_info._summary().splitlines()) == 73 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"attr, expected, comparison", | ||
[ | ||
["access", "Running", None], | ||
["application_directory", "iocxxx", "end"], | ||
["engineer", "engineer", None], | ||
["epics_version", "EPICS", "start"], | ||
["kernel_version", "Linux", "start"], | ||
["kernel_version", "x86_64", "end"], | ||
["location", "location", None], | ||
["records_count", 100, ">="], | ||
] | ||
) | ||
def test_running(attr, expected, comparison): | ||
gp_info = IocStatsDevice(IOC, name="gp_info") | ||
gp_info.wait_for_connection() | ||
assert gp_info.connected | ||
|
||
assert hasattr(gp_info, attr) | ||
value = getattr(gp_info, attr).get() | ||
if comparison == "start": | ||
assert value.startswith(expected) | ||
elif comparison == "end": | ||
assert value.endswith(expected) | ||
elif comparison == "find": | ||
assert value.find(expected) >= 0 | ||
elif comparison == ">=": | ||
assert value >= 0 | ||
else: | ||
assert value == expected | ||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2022, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,23 @@ | |
|
||
|
||
IOC = "gp:" | ||
TEST_SSEQ_PV = f"{IOC}userStringSeq10" | ||
|
||
|
||
def test_sseq_read(): | ||
sseq = SseqRecord(TEST_SSEQ_PV, name="sseq") | ||
def test_read(): | ||
sseq = SseqRecord(f"{IOC}userStringSeq10", name="sseq") | ||
assert sseq is not None | ||
sseq.wait_for_connection() | ||
|
||
r = sseq.read() | ||
assert len(r) == 20 | ||
assert len(sseq.read_attrs) == 31 | ||
assert len(sseq.configuration_attrs) == 109 | ||
assert len(sseq._summary().splitlines()) == 276 | ||
|
||
|
||
def test_sseq_reset(): | ||
user = UserStringSequenceDevice(IOC, name="user") | ||
user.wait_for_connection() | ||
user.enable.put("Enable") | ||
assert len(user.read()) == 200 | ||
|
||
sseq = user.sseq10 | ||
assert isinstance(sseq, SseqRecord) | ||
|
@@ -44,3 +45,13 @@ def test_sseq_reset(): | |
user.reset() | ||
assert step.input_pv.get() == "" | ||
assert step.string_value.get() == f"{0:.5f}" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2022, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import time | ||
|
||
from ..swait import setup_random_number_swait | ||
from ..swait import SwaitRecord | ||
from ..swait import UserCalcsDevice | ||
|
||
|
||
IOC = "gp:" | ||
|
||
|
||
def test_read(): | ||
swait = SwaitRecord(f"{IOC}userCalc10", name="sseq") | ||
assert swait is not None | ||
swait.wait_for_connection() | ||
|
||
assert len(swait.read_attrs) == 12 | ||
assert len(swait.configuration_attrs) == 61 | ||
assert len(swait._summary().splitlines()) == 152 | ||
|
||
|
||
def test_swait_reset(): | ||
user = UserCalcsDevice(IOC, name="user") | ||
user.wait_for_connection() | ||
user.enable.put("Enable") | ||
assert len(user.read()) == 130 | ||
|
||
swait = user.calc10 | ||
assert isinstance(swait, SwaitRecord) | ||
swait.enable.put("E") # Note: only "E" | ||
|
||
setup_random_number_swait(swait) | ||
time.sleep(0.2) | ||
assert swait.description.get() == "uniform random numbers" | ||
assert swait.calculation.get() == "RNDM" | ||
v1 = swait.calculated_value.get() | ||
time.sleep(0.2) | ||
assert v1 != swait.calculated_value.get() | ||
|
||
swait.reset() | ||
assert swait.description.get() == swait.prefix | ||
assert swait.calculation.get() == "0" | ||
v1 = swait.calculated_value.get() | ||
time.sleep(0.2) | ||
assert v1 == swait.calculated_value.get() | ||
|
||
# ----------------------------------------------------------------------------- | ||
# :author: Pete R. Jemian | ||
# :email: [email protected] | ||
# :copyright: (c) 2017-2022, UChicago Argonne, LLC | ||
# | ||
# Distributed under the terms of the Creative Commons Attribution 4.0 International Public License. | ||
# | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters