Spaces:
Sleeping
Sleeping
rmm
commited on
Commit
·
51fd535
1
Parent(s):
de87a9b
test: fixed error in indexing for the observation overrides
Browse files- tests/test_main.py +15 -13
tests/test_main.py
CHANGED
@@ -163,7 +163,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
|
|
163 |
debug_check_images(at, "before clicking infer. ")
|
164 |
_cprint(f"[I] buffering called {wrapped_buffer_uploaded_files_allowed_once.called} times", OKGREEN)
|
165 |
TEST_ML = True
|
166 |
-
SKIP_CHECK_OVERRIDE =
|
167 |
# 4. launch ML inference by clicking the button
|
168 |
if TEST_ML:
|
169 |
# infer_button = at.tabs[0].button[0]
|
@@ -206,14 +206,14 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
|
|
206 |
|
207 |
|
208 |
# 5. manually override the class of one of the observations
|
209 |
-
idx_to_override = 1
|
210 |
-
infer_tab.selectbox[idx_to_override].select_index(20).run() # FRAGILE!
|
211 |
|
212 |
# 5-TEST.
|
213 |
# - expect that all class_overriden are False, except for the one we just set
|
214 |
# - also expect there still to be num_files*4 images (2+6 per file) etc
|
215 |
for i, obs in enumerate(at.session_state.observations.values()):
|
216 |
-
|
217 |
assert isinstance(obs, InputObservation)
|
218 |
if not SKIP_CHECK_OVERRIDE:
|
219 |
if i == idx_to_override:
|
@@ -237,7 +237,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
|
|
237 |
|
238 |
assert at.session_state.workflow_fsm.current_state == 'manual_inspection_completed'
|
239 |
for i, obs in enumerate(at.session_state.observations.values()):
|
240 |
-
|
241 |
assert isinstance(obs, InputObservation)
|
242 |
if not SKIP_CHECK_OVERRIDE:
|
243 |
if i == idx_to_override:
|
@@ -245,8 +245,13 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
|
|
245 |
else:
|
246 |
assert obs.class_overriden == False
|
247 |
|
248 |
-
# we have to trigger a manual refresh?
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
250 |
infer_tab = at.tabs[0]
|
251 |
upload_button = infer_tab.button[0]
|
252 |
assert upload_button.disabled == False
|
@@ -271,17 +276,14 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
|
|
271 |
# - no more button on the main area
|
272 |
|
273 |
assert at.session_state.workflow_fsm.current_state == 'data_uploaded'
|
274 |
-
|
275 |
-
print(at.toast)
|
276 |
assert len(at.toast) == num_files
|
|
|
277 |
|
278 |
img_elems = infer_tab.get("imgs")
|
279 |
assert len(img_elems) == num_files*4
|
280 |
-
|
281 |
assert len(infer_tab.selectbox) == 1
|
282 |
-
|
283 |
-
print(at.button)
|
284 |
-
print(infer_tab.button)
|
285 |
|
286 |
|
287 |
|
|
|
163 |
debug_check_images(at, "before clicking infer. ")
|
164 |
_cprint(f"[I] buffering called {wrapped_buffer_uploaded_files_allowed_once.called} times", OKGREEN)
|
165 |
TEST_ML = True
|
166 |
+
SKIP_CHECK_OVERRIDE = False
|
167 |
# 4. launch ML inference by clicking the button
|
168 |
if TEST_ML:
|
169 |
# infer_button = at.tabs[0].button[0]
|
|
|
206 |
|
207 |
|
208 |
# 5. manually override the class of one of the observations
|
209 |
+
idx_to_override = 1 # don't forget, we also have the page selector first.
|
210 |
+
infer_tab.selectbox[idx_to_override + 1].select_index(20).run() # FRAGILE!
|
211 |
|
212 |
# 5-TEST.
|
213 |
# - expect that all class_overriden are False, except for the one we just set
|
214 |
# - also expect there still to be num_files*4 images (2+6 per file) etc
|
215 |
for i, obs in enumerate(at.session_state.observations.values()):
|
216 |
+
_cprint(f"obs {i}: {obs.class_overriden} {obs.to_dict()}", OKBLUE)
|
217 |
assert isinstance(obs, InputObservation)
|
218 |
if not SKIP_CHECK_OVERRIDE:
|
219 |
if i == idx_to_override:
|
|
|
237 |
|
238 |
assert at.session_state.workflow_fsm.current_state == 'manual_inspection_completed'
|
239 |
for i, obs in enumerate(at.session_state.observations.values()):
|
240 |
+
_cprint(f"obs {i}: {obs.class_overriden} {obs.to_dict()}", OKBLUE)
|
241 |
assert isinstance(obs, InputObservation)
|
242 |
if not SKIP_CHECK_OVERRIDE:
|
243 |
if i == idx_to_override:
|
|
|
245 |
else:
|
246 |
assert obs.class_overriden == False
|
247 |
|
248 |
+
# we have to trigger a manual refresh? no, it seems that sometimes the tests fail, maybe
|
249 |
+
# because the script is slow? it is not unique to here, various points that usually pass
|
250 |
+
# occasionally fail because elements haven't yet been drawn. I suppose the timing aspect
|
251 |
+
# internally by AppTest is not perfect (selenium has moved from explicit to implicit waits,
|
252 |
+
# though I didn't look too deeply whether apptest also has an explicit wait mechanism)
|
253 |
+
# # time.sleep(1)
|
254 |
+
# #at.run()
|
255 |
infer_tab = at.tabs[0]
|
256 |
upload_button = infer_tab.button[0]
|
257 |
assert upload_button.disabled == False
|
|
|
276 |
# - no more button on the main area
|
277 |
|
278 |
assert at.session_state.workflow_fsm.current_state == 'data_uploaded'
|
279 |
+
#print(at.toast)
|
|
|
280 |
assert len(at.toast) == num_files
|
281 |
+
infer_tab = at.tabs[0]
|
282 |
|
283 |
img_elems = infer_tab.get("imgs")
|
284 |
assert len(img_elems) == num_files*4
|
|
|
285 |
assert len(infer_tab.selectbox) == 1
|
286 |
+
assert len(infer_tab.button) == 0
|
|
|
|
|
287 |
|
288 |
|
289 |
|