Controller/tests/test_jobschedule.py

22 lines
668 B
Python

# coding=utf-8
from datetime import datetime
import pytest
from tsgrain_controller import models
@pytest.mark.parametrize('date, repeat, expect', [
(datetime(2022, 1, 18, 10, 30, 0), False, True),
(datetime(2022, 1, 18, 10, 30, 13), False, True),
(datetime(2022, 1, 18, 10, 29, 59), False, False),
(datetime(2022, 1, 19, 10, 30, 0), False, False),
(datetime(2022, 1, 19, 10, 30, 0), True, True),
])
def test_job_check(date, repeat, expect):
date_now = datetime(2022, 1, 18, 10, 30, 0)
job = models.Job(date, 30, [1], True, repeat)
assert job.check(date_now) is expect
job.enable = False
assert job.check(date_now) is False