33import json
44from one .api import ONE
55from ibllib .tests import TEST_DB
6+ import random
7+ import string
68
79import ibllib .qc .critical_reasons as usrpmt
810
@@ -25,22 +27,15 @@ def setUp(self) -> None:
2527 one .alyx .clear_rest_cache ()
2628 self .sess_id = one .alyx .rest ('sessions' , 'list' , task_protocol = 'ephys' )[0 ]['url' ][- 36 :]
2729
28- # Make sure tests use correct insertion ID
29- # 1. Find and delete any previous insertions
30- ins = one .alyx .get ('/insertions' , clobber = True )
31- if len (ins ) > 0 :
32- ins_id = [item ['id' ] for item in ins ]
33- for ins_id_i in ins_id :
34- one .alyx .rest ('insertions' , 'delete' , id = ins_id_i )
35- # 2. Create new insertion
36- data = {'name' : 'probe01' ,
30+ # Make new insertion with random name
31+ data = {'name' : '' .join (random .choices (string .ascii_letters , k = 5 )),
3732 'session' : self .sess_id ,
3833 'model' : '3A' ,
3934 'json' : None ,
4035 'datasets' : []}
4136 one .alyx .rest ('insertions' , 'create' , data = data )
4237 # 3. Save ins id in global variable for test access
43- self .ins_id = one .alyx .rest ('insertions' , 'list' , no_cache = True )[0 ]['id' ]
38+ self .ins_id = one .alyx .rest ('insertions' , 'list' , session = self . sess_id , name = data [ 'name' ], no_cache = True )[0 ]['id' ]
4439
4540 def test_reason_addnumberstr (self ):
4641 outstr = usrpmt ._reason_addnumberstr (reason_list = ['a' , 'b' ])
0 commit comments