Skip to content

Commit 799f4c0

Browse files
Add tests for blocking argument & global setting
1 parent ae2b6e4 commit 799f4c0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_records.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515

1616
from softioc import asyncio_dispatcher, builder, softioc
17+
from softioc.device import set_blocking
1718

1819
# Test file for miscellaneous tests related to records
1920

@@ -180,6 +181,35 @@ def test_pini_always_on():
180181
assert mbbi.PINI.Value() == "YES"
181182

182183

184+
def check_record_blocking_attributes(record):
185+
"""Helper function to assert expected attributes exist for a blocking
186+
record"""
187+
assert record._blocking is True
188+
assert record._callback != 0
189+
190+
def test_blocking_creates_attributes():
191+
"""Test that setting the blocking flag on record creation creates the
192+
expected attributes"""
193+
ao1 = builder.aOut("OUTREC1", blocking=True)
194+
check_record_blocking_attributes(ao1)
195+
196+
ao2 = builder.aOut("OUTREC2", blocking=False)
197+
assert ao2._blocking is False
198+
199+
def test_blocking_global_flag_creates_attributes():
200+
"""Test that the global blocking flag creates the expected attributes"""
201+
set_blocking(True)
202+
bo1 = builder.boolOut("OUTREC1")
203+
204+
check_record_blocking_attributes(bo1)
205+
206+
set_blocking(False)
207+
bo2 = builder.boolOut("OUTREC2")
208+
assert bo2._blocking is False
209+
210+
bo3 = builder.boolOut("OUTREC3", blocking=True)
211+
check_record_blocking_attributes(bo3)
212+
183213

184214
def validate_fixture_names(params):
185215
"""Provide nice names for the out_records fixture in TestValidate class"""

0 commit comments

Comments
 (0)