9
9
log ,
10
10
create_random_prefix ,
11
11
requires_cothread ,
12
- _clear_records ,
13
12
WAVEFORM_LENGTH ,
14
13
TIMEOUT ,
15
14
select_and_recv ,
19
18
from softioc import asyncio_dispatcher , builder , softioc
20
19
from softioc import alarm
21
20
from softioc .device import SetBlocking
21
+ from softioc .device_core import LookupRecord , LookupRecordList
22
22
23
23
# Test file for miscellaneous tests related to records
24
24
@@ -38,7 +38,6 @@ def test_records(tmp_path):
38
38
# Ensure we definitely unload all records that may be hanging over from
39
39
# previous tests, then create exactly one instance of expected records.
40
40
from sim_records import create_records
41
- _clear_records ()
42
41
create_records ()
43
42
44
43
path = str (tmp_path / "records.db" )
@@ -228,6 +227,29 @@ def test_setting_alarm_invalid_keywords(creation_func):
228
227
229
228
assert e .value .args [0 ] == 'Can\' t specify both status and STAT'
230
229
230
+ def test_clear_records ():
231
+ """Test that clearing the known records allows creation of a record of the
232
+ same name afterwards"""
233
+ record_name = "NEW-RECORD"
234
+
235
+ builder .aOut (record_name )
236
+
237
+ # First check that we cannot create two of the same name
238
+ with pytest .raises (AssertionError ):
239
+ builder .aOut (record_name )
240
+
241
+ builder .ClearRecords ()
242
+
243
+ # Then confirm we can create one of this name
244
+ builder .aOut (record_name )
245
+
246
+ # Finally prove that the underlying record holder contains only one record
247
+ assert LookupRecord (record_name )
248
+ assert len (LookupRecordList ()) == 1
249
+ for key , val in LookupRecordList ():
250
+ assert key == record_name
251
+
252
+
231
253
232
254
def validate_fixture_names (params ):
233
255
"""Provide nice names for the out_records fixture in TestValidate class"""
0 commit comments