def test_registry():
    s = TaskScheduler()
    s.every("businessday").at("10:00").do(job, x="hello", y="world")  # Job
    s.on('2019-05-16').do(job, x="hello", y="world")  # OneTimeJob
    s.every(5).at("10:00").do(job, x="hello", y="world")  # RepeatJob
    s.every('2nd').strict_date(False).at("10:00").do(job, x="hello",
                                                     y="world")  # MonthlyJob
    assert len(s.jobs) == 4
def test_onetime():
    yesterday = dt.now() - timedelta(days=1)
    tomorrow = (dt.now() + timedelta(days=1)).replace(hour=23,
                                                      minute=59,
                                                      second=0,
                                                      microsecond=0)
    s = TaskScheduler()
    s.on(yesterday.strftime("%Y-%m-%d")).at("23:59").do(job,
                                                        x="hello",
                                                        y="world")
    s.on(tomorrow.strftime("%Y-%m-%d")).at("23:59").do(job,
                                                       x="hello",
                                                       y="world")
    for j in s.jobs:
        assert (j.next_timestamp == dt.timestamp(tomorrow)
                or j.next_timestamp == 0)
    assert len(s.jobs) == 2
    s.check()
    assert len(s.jobs) == 1