1
0
Fork 0
platypush/tests/test_cron.py
Fabio Manganiello 04b1dad6d8
Removed test_cron_execution_upon_system_clock_change.
The test is too brittle as it depends on small mocked clock skews and it
can easily fail.
2023-05-04 00:11:11 +02:00

32 lines
680 B
Python

import queue
import pytest
import time
test_timeout = 10
cron_queue = queue.Queue()
def _test_cron_queue(expected_msg: str):
msg = None
test_start = time.time()
while time.time() - test_start <= test_timeout and msg != expected_msg:
try:
msg = cron_queue.get(block=True, timeout=test_timeout)
except queue.Empty:
break
assert msg == expected_msg, 'The expected cronjob has not been executed'
def test_cron_execution():
"""
Test that the cronjob in ``../etc/scripts/test_cron.py`` runs successfully.
"""
_test_cron_queue('cron_test')
if __name__ == '__main__':
pytest.main()
# vim:sw=4:ts=4:et: