Skip to content

Commit

Permalink
TST #632 add wait after reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jan 26, 2022
1 parent 135c34c commit c6a7731
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apstools/synApps/tests/test_swait.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import pytest
import time

from ..swait import setup_random_number_swait
from ..swait import SwaitRecord
from ..swait import UserCalcN
from ..swait import UserCalcsDevice
from ...tests import common_attribute_quantities_test
from ...tests import IOC
# from ...tests import SHORT_DELAY_FOR_EPICS_IOC_DATABASE_PROCESSING
from ...tests import short_delay_for_EPICS_IOC_database_processing


@pytest.mark.parametrize(
Expand Down Expand Up @@ -44,18 +43,19 @@ def test_userCalcs_reset():
swait.enable.put("E") # Note: only "E"

setup_random_number_swait(swait)
time.sleep(0.2)
short_delay_for_EPICS_IOC_database_processing(0.2)
assert swait.description.get() == "uniform random numbers"
assert swait.calculation.get() == "RNDM"
v1 = swait.calculated_value.get()
time.sleep(0.2)
short_delay_for_EPICS_IOC_database_processing(0.2)
assert v1 != swait.calculated_value.get()

swait.reset()
short_delay_for_EPICS_IOC_database_processing()
assert swait.description.get() == swait.prefix
assert swait.calculation.get() == "0"
v1 = swait.calculated_value.get()
time.sleep(0.2)
short_delay_for_EPICS_IOC_database_processing(0.2)
assert v1 == swait.calculated_value.get()

# -----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions apstools/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import time
import warnings

IOC = "gp:"
MAX_TESTING_RETRIES = 3
SHORT_DELAY_FOR_EPICS_IOC_DATABASE_PROCESSING = 2. / 60 # two 60Hz clock cycles


def short_delay_for_EPICS_IOC_database_processing(delay=None):
if delay is None:
delay = SHORT_DELAY_FOR_EPICS_IOC_DATABASE_PROCESSING
time.sleep(delay)


def common_attribute_quantities_test(device, pv, connect, attr, expected):
"""
Verify the quantities of an attribute.
Expand Down

0 comments on commit c6a7731

Please sign in to comment.