Skip to content

Commit 3a5586e

Browse files
Add tests for issues #81 and #67
1 parent b61327c commit 3a5586e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/test_records.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,55 @@ def test_waveform_construction():
131131
with pytest.raises(AssertionError):
132132
builder.WaveformIn("WI11", length=11, NELM=12)
133133

134+
def test_drvhl_hlopr_defaults():
135+
"""Test the DRVH/L and H/LOPR default settings"""
136+
# DRVH/L doesn't exist on In records
137+
ai = builder.aIn("FOO")
138+
# KeyError as fields with no value are simply not present in
139+
# epicsdbbuilder's dictionary of fields
140+
with pytest.raises(KeyError):
141+
assert ai.LOPR.Value() is None
142+
with pytest.raises(KeyError):
143+
assert ai.HOPR.Value() is None
144+
145+
ao = builder.aOut("BAR")
146+
with pytest.raises(KeyError):
147+
assert ao.LOPR.Value() is None
148+
with pytest.raises(KeyError):
149+
assert ao.HOPR.Value() is None
150+
with pytest.raises(KeyError):
151+
assert ao.DRVH.Value() is None
152+
with pytest.raises(KeyError):
153+
assert ao.DRVL.Value() is None
154+
155+
def test_hlopr_inherits_drvhl():
156+
"""Test that H/LOPR values are set to the DRVH/L values"""
157+
lo = builder.longOut("ABC", DRVH=5, DRVL=10)
158+
159+
assert lo.DRVH.Value() == 5
160+
assert lo.HOPR.Value() == 5
161+
assert lo.DRVL.Value() == 10
162+
assert lo.LOPR.Value() == 10
163+
164+
def test_hlopr_dvrhl_different_values():
165+
"""Test you can set H/LOPR and DRVH/L to different values"""
166+
ao = builder.aOut("DEF", DRVL=1, LOPR=2, HOPR=3, DRVH=4)
167+
168+
assert ao.DRVL.Value() == 1
169+
assert ao.LOPR.Value() == 2
170+
assert ao.HOPR.Value() == 3
171+
assert ao.DRVH.Value() == 4
172+
173+
def test_pini_always_on():
174+
"""Test that PINI is always on for in records regardless of initial_value"""
175+
bi = builder.boolIn("AAA")
176+
assert bi.PINI.Value() == "YES"
177+
178+
mbbi = builder.mbbIn("BBB", initial_value=5)
179+
assert mbbi.PINI.Value() == "YES"
180+
181+
182+
134183
def validate_fixture_names(params):
135184
"""Provide nice names for the out_records fixture in TestValidate class"""
136185
return params[0].__name__

0 commit comments

Comments
 (0)