first commit
This commit is contained in:
24
backend/tests/test_scheduler.py
Normal file
24
backend/tests/test_scheduler.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from app.core.cron_utils import CronValidationError, describe_cron_expression, preview_next_runs, validate_cron_expression
|
||||
|
||||
|
||||
def test_validate_cron_expression_accepts_daily_schedule():
|
||||
validate_cron_expression('15 2 * * *', 'Europe/Warsaw')
|
||||
|
||||
|
||||
def test_validate_cron_expression_rejects_invalid_schedule():
|
||||
try:
|
||||
validate_cron_expression('bad cron', 'Europe/Warsaw')
|
||||
except CronValidationError:
|
||||
assert True
|
||||
return
|
||||
assert False, 'invalid cron should raise'
|
||||
|
||||
|
||||
def test_preview_next_runs_returns_future_datetimes():
|
||||
runs = preview_next_runs('0 3 * * 1', 'Europe/Warsaw', count=2)
|
||||
assert len(runs) == 2
|
||||
assert runs[0] < runs[1]
|
||||
|
||||
|
||||
def test_describe_cron_expression_humanizes_common_patterns():
|
||||
assert describe_cron_expression('0 2 * * *') == 'Every day at 02:00'
|
||||
Reference in New Issue
Block a user