Skip to content

Commit 934f9da

Browse files
committed
Remove double import; delete session notes first on teardown
1 parent 7c2a821 commit 934f9da

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

ibllib/tests/qc/test_critical_reasons.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import random
55
import string
66
import datetime
7-
import numpy as np
87

8+
import numpy as np
99
import requests
1010
from one.api import ONE
11+
from one.registration import RegistrationClient
1112

1213
from ibllib.tests import TEST_DB
1314
import ibllib.qc.critical_reasons as usrpmt
14-
from one.registration import RegistrationClient
1515

1616
one = ONE(**TEST_DB)
1717

@@ -33,7 +33,6 @@ def setUp(self) -> None:
3333
one.alyx.clear_rest_cache()
3434
# Create new session on database with a random date to avoid race conditions
3535
date = str(datetime.date(2022, rng.integers(1, 12), rng.integers(1, 28)))
36-
from one.registration import RegistrationClient
3736
_, eid = RegistrationClient(one).create_new_session('ZM_1150', date=date)
3837
eid = str(eid)
3938
# Currently the task protocol of a session must contain 'ephys' in order to create an insertion!
@@ -144,6 +143,10 @@ def tearDown(self) -> None:
144143
except requests.HTTPError as ex:
145144
if ex.errno != 404:
146145
raise ex
146+
147+
notes = one.alyx.rest('notes', 'list', django=f'object_id,{self.sess_id}', no_cache=True)
148+
for n in notes:
149+
one.alyx.rest('notes', 'delete', id=n['id'])
147150
text = '"title": "=== EXPERIMENTER REASON(S)'
148151
notes = one.alyx.rest('notes', 'list', django=f'text__icontains,{text}', no_cache=True)
149152
for n in notes:
@@ -153,10 +156,6 @@ def tearDown(self) -> None:
153156
for n in notes:
154157
one.alyx.rest('notes', 'delete', n['id'])
155158

156-
note = one.alyx.rest('notes', 'list', django=f'object_id,{self.sess_id}', no_cache=True)
157-
for no in note:
158-
one.alyx.rest('notes', 'delete', id=no['id'])
159-
160159

161160
class TestSignOffNote(unittest.TestCase):
162161
def setUp(self) -> None:

ibllib/tests/test_ephys.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def tearDownClass(cls) -> None:
140140
cls.tempdir.cleanup()
141141

142142
def setUp(self) -> None:
143-
144143
self.eid = 'b1c968ad-4874-468d-b2e4-5ffa9b9964e9'
145144
# make a temp probe insertion
146145
self.pname = 'probe02'

0 commit comments

Comments
 (0)