|
14 | 14 | ) |
15 | 15 |
|
16 | 16 | from softioc import asyncio_dispatcher, builder, softioc |
| 17 | +from softioc.device import set_blocking |
17 | 18 |
|
18 | 19 | # Test file for miscellaneous tests related to records |
19 | 20 |
|
@@ -180,6 +181,35 @@ def test_pini_always_on(): |
180 | 181 | assert mbbi.PINI.Value() == "YES" |
181 | 182 |
|
182 | 183 |
|
| 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 | + |
183 | 213 |
|
184 | 214 | def validate_fixture_names(params): |
185 | 215 | """Provide nice names for the out_records fixture in TestValidate class""" |
|
0 commit comments