99 log ,
1010 create_random_prefix ,
1111 requires_cothread ,
12- _clear_records ,
1312 WAVEFORM_LENGTH ,
1413 TIMEOUT ,
1514 select_and_recv ,
1918from softioc import asyncio_dispatcher , builder , softioc
2019from softioc import alarm
2120from softioc .device import SetBlocking
21+ from softioc .device_core import LookupRecord , LookupRecordList
2222
2323# Test file for miscellaneous tests related to records
2424
@@ -38,7 +38,6 @@ def test_records(tmp_path):
3838 # Ensure we definitely unload all records that may be hanging over from
3939 # previous tests, then create exactly one instance of expected records.
4040 from sim_records import create_records
41- _clear_records ()
4241 create_records ()
4342
4443 path = str (tmp_path / "records.db" )
@@ -228,6 +227,35 @@ def test_setting_alarm_invalid_keywords(creation_func):
228227
229228 assert e .value .args [0 ] == 'Can\' t specify both status and STAT'
230229
230+ def test_clear_records ():
231+ """Test that clearing the known records allows creation of a record of the
232+ same name afterwards"""
233+
234+ device_name = create_random_prefix ()
235+ builder .SetDeviceName (device_name )
236+
237+ record_name = "NEW-RECORD"
238+
239+ builder .aOut (record_name )
240+
241+ # First check that we cannot create two of the same name
242+ with pytest .raises (AssertionError ):
243+ builder .aOut (record_name )
244+
245+ builder .ClearRecords ()
246+
247+ # Then confirm we can create one of this name
248+ builder .aOut (record_name )
249+
250+ # Finally prove that the underlying record holder contains only one record
251+ # Records are stored as full device:record name
252+ full_name = device_name + ":" + record_name
253+ assert LookupRecord (full_name )
254+ assert len (LookupRecordList ()) == 1
255+ for key , val in LookupRecordList ():
256+ assert key == full_name
257+
258+
231259
232260def validate_fixture_names (params ):
233261 """Provide nice names for the out_records fixture in TestValidate class"""
0 commit comments