rmm commited on
Commit
3735c6f
·
1 Parent(s): 51fd535

test: basic measure of timing for each phase

Browse files
tests/test_demo_input_sidebar.py CHANGED
@@ -85,6 +85,7 @@ OKBLUE = '\033[94m'
85
  OKGREEN = '\033[92m'
86
  OKCYAN = '\033[96m'
87
  FAIL = '\033[91m'
 
88
  ENDC = '\033[0m'
89
 
90
  def _cprint(msg:str, color:str=OKCYAN):
 
85
  OKGREEN = '\033[92m'
86
  OKCYAN = '\033[96m'
87
  FAIL = '\033[91m'
88
+ PURPLE = '\033[35m'
89
  ENDC = '\033[0m'
90
 
91
  def _cprint(msg:str, color:str=OKCYAN):
tests/test_main.py CHANGED
@@ -19,7 +19,7 @@ from test_demo_input_sidebar import (
19
  verify_initial_session_state, verify_session_state_after_processing_files,
20
  wrapped_buffer_uploaded_files_allowed_once)
21
 
22
- from test_demo_input_sidebar import _cprint, OKBLUE, OKGREEN, OKCYAN, FAIL, ENDC
23
 
24
  TIMEOUT = 15
25
  SCRIPT_UNDER_TEST = "src/main.py"
@@ -54,7 +54,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
54
  t0 = time.time()
55
  at = AppTest.from_file(SCRIPT_UNDER_TEST, default_timeout=TIMEOUT).run()
56
  t1 = time.time()
57
- _cprint(f"[T] time to load: {t1-t0}", OKCYAN)
58
  verify_initial_session_state(at)
59
 
60
  # 1-Test: at this initial state, we expect:
@@ -85,7 +85,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
85
  t2 = time.time()
86
  at.run()
87
  t3 = time.time()
88
- _cprint(f"[T] time to run with file processing: {t3-t2}", OKCYAN)
89
 
90
  # 2-Test: after uploading the files, we should have:
91
  # - the workflow state moved on to 'data_entry_complete'
@@ -108,7 +108,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
108
  # 3. data entry complete, click the validate button
109
  at.sidebar.button[1].click().run()
110
  t4 = time.time()
111
- _cprint(f"[T] time to run step 3: {t4-t3}", OKCYAN)
112
 
113
  # 3-Test: after validating the data, we should have:
114
  # - the state (backend) should move to data_entry_validated
@@ -171,7 +171,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
171
  # now test the ML step
172
  infer_button.click().run()
173
  t5 = time.time()
174
- _cprint(f"[T] time to run with step 4: {t5-t4}", OKCYAN)
175
 
176
  # 4-Test: after clicking the infer button, we should have:
177
  # - workflow should have moved on to 'ml_classification_completed'
@@ -226,7 +226,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
226
  confirm_button = infer_tab.button[0]
227
  confirm_button.click().run()
228
  t6 = time.time()
229
- _cprint(f"[T] time to run with step 6: {t6-t5}", OKCYAN)
230
 
231
  # 6-TEST. Now we expect to see:
232
  # - the workflow state should be 'manual_inspection_completed'
@@ -265,7 +265,7 @@ def test_click_validate_after_data_entry(mock_file_rv: MagicMock, mock_uploadedF
265
  # 7. upload the observations
266
  upload_button.click().run()
267
  t7 = time.time()
268
- _cprint(f"[T] time to run with step 7: {t7-t6}", OKCYAN)
269
 
270
  # 7-TEST. Now we expect to see:
271
  # - workflow state should be 'data_uploaded'
 
19
  verify_initial_session_state, verify_session_state_after_processing_files,
20
  wrapped_buffer_uploaded_files_allowed_once)
21
 
22
+ from test_demo_input_sidebar import _cprint, OKBLUE, OKGREEN, OKCYAN, FAIL, PURPLE
23
 
24
  TIMEOUT = 15
25
  SCRIPT_UNDER_TEST = "src/main.py"
 
54
  t0 = time.time()
55
  at = AppTest.from_file(SCRIPT_UNDER_TEST, default_timeout=TIMEOUT).run()
56
  t1 = time.time()
57
+ _cprint(f"[T] time to load: {t1-t0:.2f}s", PURPLE)
58
  verify_initial_session_state(at)
59
 
60
  # 1-Test: at this initial state, we expect:
 
85
  t2 = time.time()
86
  at.run()
87
  t3 = time.time()
88
+ _cprint(f"[T] time to run with file processing: {t3-t2:.2f}s", PURPLE)
89
 
90
  # 2-Test: after uploading the files, we should have:
91
  # - the workflow state moved on to 'data_entry_complete'
 
108
  # 3. data entry complete, click the validate button
109
  at.sidebar.button[1].click().run()
110
  t4 = time.time()
111
+ _cprint(f"[T] time to run step 3: {t4-t3:.2f}s", PURPLE)
112
 
113
  # 3-Test: after validating the data, we should have:
114
  # - the state (backend) should move to data_entry_validated
 
171
  # now test the ML step
172
  infer_button.click().run()
173
  t5 = time.time()
174
+ _cprint(f"[T] time to run step 4: {t5-t4:.2f}s", PURPLE)
175
 
176
  # 4-Test: after clicking the infer button, we should have:
177
  # - workflow should have moved on to 'ml_classification_completed'
 
226
  confirm_button = infer_tab.button[0]
227
  confirm_button.click().run()
228
  t6 = time.time()
229
+ _cprint(f"[T] time to run step 5: {t6-t5:.2f}s", PURPLE)
230
 
231
  # 6-TEST. Now we expect to see:
232
  # - the workflow state should be 'manual_inspection_completed'
 
265
  # 7. upload the observations
266
  upload_button.click().run()
267
  t7 = time.time()
268
+ _cprint(f"[T] time to run step 6: {t7-t6:.2f}s", PURPLE)
269
 
270
  # 7-TEST. Now we expect to see:
271
  # - workflow state should be 'data_uploaded'