Skip to content

Commit c4807bd

Browse files
committed
randomize probe name used for critical reason test
1 parent ef58861 commit c4807bd

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

ibllib/tests/qc/test_critical_reasons.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import json
44
from one.api import ONE
55
from ibllib.tests import TEST_DB
6+
import random
7+
import string
68

79
import 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

Comments
 (0)