Skip to content

Commit ad592b5

Browse files
committed
update progress bar unit tests
1 parent 67d99e5 commit ad592b5

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

tests/run_all_tests.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ printf "0" | ./slips.py -k
66

77
# run all unit tests, -n *5 means distribute tests on 5 different process
88
# -s to see print statements as they are executed
9-
python3 -m pytest tests/ --ignore="tests/test_database.py" --ignore="tests/integration_tests" -n 7 -p no:warnings -vvvv -s
10-
11-
## run db tests serially/using 1 worker
12-
python3 -m pytest tests/test_database.py -p no:warnings -vvvv -s
9+
python3 -m pytest tests/ --ignore="tests/integration_tests" -n 7 -p no:warnings -vvvv -s
1310

1411
# Close all redis-servers opened by the unit tests
1512
python3 tests/destrctor.py

tests/test_progress_bar.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,19 @@ def test_remove_stats():
167167

168168

169169
@pytest.mark.parametrize(
170-
"total_flows, current_n",
170+
"total_flows, current_n, keyboard_int",
171171
[
172172
# testcase1: Normal case
173-
(100, 100),
173+
(100, 100, 0),
174174
# testcase2: Edge case - zero flows
175-
(0, 0),
175+
(0, 0, 1),
176176
# testcase3: Large number of flows
177-
(1000000, 1000000),
177+
(1000000, 1000000, 0),
178178
],
179179
)
180-
def test_shutdown_gracefully(
181-
total_flows,
182-
current_n,
183-
):
180+
def test_shutdown_gracefully(total_flows, current_n, keyboard_int):
184181
pbar = ModuleFactory().create_progress_bar_obj()
182+
pbar.keyboard_int_ctr = keyboard_int
185183
pbar.total_flows = total_flows
186184
pbar.pbar_finished = Event()
187185

@@ -193,10 +191,13 @@ def test_shutdown_gracefully(
193191
"tqdm.auto.tqdm.write"
194192
) as mock_write:
195193
pbar.shutdown_gracefully()
196-
197194
mock_remove_stats.assert_called_once()
198-
mock_write.assert_called_once_with(
199-
"Profiler is done reading all flows. "
200-
"Slips is now processing them."
201-
)
195+
196+
if not keyboard_int:
197+
mock_write.assert_not_called()
198+
else:
199+
mock_write.assert_called_once_with(
200+
"Profiler is done reading all flows. "
201+
"Slips is now processing them."
202+
)
202203
assert pbar.pbar_finished.is_set()

0 commit comments

Comments
 (0)