This commit is contained in:
@@ -3,18 +3,28 @@ import threading
|
|||||||
import pytest
|
import pytest
|
||||||
import epics
|
import epics
|
||||||
from epics.pv import PV
|
from epics.pv import PV
|
||||||
|
from epics.pv import _PVcache_
|
||||||
from slic.utils.hastyepics import *
|
from slic.utils.hastyepics import *
|
||||||
|
|
||||||
|
def _in_pv_cache(pvname: str) -> bool:
|
||||||
|
return any(k[0] == pvname for k in _PVcache_.keys())
|
||||||
|
|
||||||
# ============================
|
# ============================
|
||||||
# Tests
|
# Tests
|
||||||
# ============================
|
# ============================
|
||||||
|
|
||||||
def test_get_pv_connect_false_and_true():
|
def test_get_pv_connect_false_and_true():
|
||||||
pv = get_pv("TEST:SIM:VAL", connect=False)
|
name = "TEST:SIM:VAL"
|
||||||
assert isinstance(pv, PV)
|
assert not _in_pv_cache(name)
|
||||||
assert not pv.connected
|
|
||||||
|
|
||||||
pv2 = get_pv("TEST:SIM:VAL", connect=True, timeout=2.0)
|
pv = get_pv(name, connect=False)
|
||||||
|
assert isinstance(pv, PV)
|
||||||
|
|
||||||
|
assert _in_pv_cache(name), "PV should be in _PVcache_ after get_pv(connect=False)"
|
||||||
|
assert not pv.connected
|
||||||
|
|
||||||
|
# Now actually connect
|
||||||
|
pv2 = get_pv(name, connect=True, timeout=2.0)
|
||||||
assert pv2.connected
|
assert pv2.connected
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user