Exemplo n.º 1
0
def test_week_2():
    trigger = CronTrigger(year=2009, week=15, day_of_week=2)
    eq_(repr(trigger), "<CronTrigger (year='2009', week='15', day_of_week='2')>")
    eq_(str(trigger), "cron[year='2009', week='15', day_of_week='2']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 4, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 2
0
def test_cron_trigger_1():
    trigger = CronTrigger(year='2009/2', month='1/3', day='5-13')
    eq_(repr(trigger), "<CronTrigger (year='2009/2', month='1/3', day='5-13')>")
    eq_(str(trigger), "cron[year='2009/2', month='1/3', day='5-13']")
    start_date = datetime(2008, 12, 1)
    correct_next_date = datetime(2009, 1, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 3
0
def test_cron_weekday_nomatch():
    trigger = CronTrigger(year=2009, month=1, day='6-10', day_of_week='0,6')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='1', day='6-10', day_of_week='0,6')>")
    eq_(str(trigger), "cron[year='2009', month='1', day='6-10', day_of_week='0,6']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = None
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 4
0
def test_cron_weekday_positional():
    trigger = CronTrigger(year=2009, month=1, day='4th wed')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='1', day='4th wed')>")
    eq_(str(trigger), "cron[year='2009', month='1', day='4th wed']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 1, 28)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 5
0
def test_week_1():
    trigger = CronTrigger(year=2009, month=2, week=8)
    eq_(repr(trigger), "<CronTrigger (year='2009', month='2', week='8')>")
    eq_(str(trigger), "cron[year='2009', month='2', week='8']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 16)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 6
0
def test_week_2():
    trigger = CronTrigger(year=2009, week=15, day_of_week=2)
    eq_(repr(trigger), "<CronTrigger (year='2009', week='15', day_of_week='2')>")
    eq_(str(trigger), "cron[year='2009', week='15', day_of_week='2']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 4, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 7
0
def test_cron_trigger_1():
    trigger = CronTrigger(year='2009/2', month='1/3', day='5-13')
    eq_(repr(trigger), "<CronTrigger (year='2009/2', month='1/3', day='5-13')>")
    eq_(str(trigger), "cron[year='2009/2', month='1/3', day='5-13']")
    start_date = datetime(2008, 12, 1)
    correct_next_date = datetime(2009, 1, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 8
0
def test_cron_year_list():
    trigger = CronTrigger(year='2009,2008')
    eq_(repr(trigger), "<CronTrigger (year='2009,2008')>")
    eq_(str(trigger), "cron[year='2009,2008']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 1, 1)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 9
0
def test_cron_year_list():
    trigger = CronTrigger(year='2009,2008')
    eq_(repr(trigger), "<CronTrigger (year='2009,2008')>")
    eq_(str(trigger), "cron[year='2009,2008']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 1, 1)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 10
0
def test_cron_weekday_positional():
    trigger = CronTrigger(year=2009, month=1, day='4th wed')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='1', day='4th wed')>")
    eq_(str(trigger), "cron[year='2009', month='1', day='4th wed']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 1, 28)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 11
0
def test_week_1():
    trigger = CronTrigger(year=2009, month=2, week=8)
    eq_(repr(trigger), "<CronTrigger (year='2009', month='2', week='8')>")
    eq_(str(trigger), "cron[year='2009', month='2', week='8']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 16)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 12
0
def test_cron_start_date():
    trigger = CronTrigger(year='2009', month='2', hour='8-10',
                          start_date='2009-02-03 11:00:00')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='2', hour='8-10', start_date='2009-02-03 11:00:00')>")
    eq_(str(trigger), "cron[year='2009', month='2', hour='8-10']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 4, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 13
0
def test_cron_extra_coverage():
    # This test has no value other than patching holes in test coverage
    trigger = CronTrigger(day='6,8')
    eq_(repr(trigger), "<CronTrigger (day='6,8')>")
    eq_(str(trigger), "cron[day='6,8']")
    start_date = datetime(2009, 12, 31)
    correct_next_date = datetime(2010, 1, 6)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 14
0
def test_cron_extra_coverage():
    # This test has no value other than patching holes in test coverage
    trigger = CronTrigger(day='6,8')
    eq_(repr(trigger), "<CronTrigger (day='6,8')>")
    eq_(str(trigger), "cron[day='6,8']")
    start_date = datetime(2009, 12, 31)
    correct_next_date = datetime(2010, 1, 6)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 15
0
def test_cron_increment_weekday():
    # Makes sure that incrementing the weekday field in the process of
    # calculating the next matching date won't cause problems
    trigger = CronTrigger(hour='5-6')
    eq_(repr(trigger), "<CronTrigger (hour='5-6')>")
    eq_(str(trigger), "cron[hour='5-6']")
    start_date = datetime(2009, 9, 25, 7)
    correct_next_date = datetime(2009, 9, 26, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 16
0
def test_cron_increment_weekday():
    # Makes sure that incrementing the weekday field in the process of
    # calculating the next matching date won't cause problems
    trigger = CronTrigger(hour='5-6')
    eq_(repr(trigger), "<CronTrigger (hour='5-6')>")
    eq_(str(trigger), "cron[hour='5-6']")
    start_date = datetime(2009, 9, 25, 7)
    correct_next_date = datetime(2009, 9, 26, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 17
0
def test_cron_weekday_nomatch():
    trigger = CronTrigger(year=2009, month=1, day='6-10', day_of_week='0,6')
    eq_(
        repr(trigger), "<CronTrigger (year='2009', month='1', "
        "day='6-10', day_of_week='0,6')>")
    eq_(str(trigger),
        "cron[year='2009', month='1', day='6-10', day_of_week='0,6']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = None
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 18
0
def test_cron_start_date():
    trigger = CronTrigger(year='2009', month='2', hour='8-10',
                          start_date='2009-02-03 11:00:00')
    eq_(repr(trigger),
        "<CronTrigger (year='2009', month='2', hour='8-10', "
        "start_date='2009-02-03 11:00:00')>")
    eq_(str(trigger), "cron[year='2009', month='2', hour='8-10']")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 4, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 19
0
def test_cron_trigger_2():
    trigger = CronTrigger(year='2009/2', month='1/3', day='5-13')
    start_date = datetime(2009, 10, 14)
    correct_next_date = datetime(2011, 1, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 20
0
def test_cron_trigger_4():
    trigger = CronTrigger(year='2012', month='2', day='last')
    eq_(repr(trigger), "<CronTrigger (year='2012', month='2', day='last')>")
    start_date = datetime(2012, 2, 1)
    correct_next_date = datetime(2012, 2, 29)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 21
0
def test_cron_trigger_4():
    trigger = CronTrigger(year='2012', month='2', day='last')
    eq_(repr(trigger), "<CronTrigger (year='2012', month='2', day='last')>")
    start_date = datetime(2012, 2, 1)
    correct_next_date = datetime(2012, 2, 29)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 22
0
def test_cron_trigger_3():
    trigger = CronTrigger(year='2009', month='2', hour='8-10')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='2', hour='8-10')>")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 1, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 23
0
def test_cron_trigger_2():
    trigger = CronTrigger(year='2009/2', month='1/3', day='5-13')
    start_date = datetime(2009, 10, 14)
    correct_next_date = datetime(2011, 1, 5)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)
Exemplo n.º 24
0
def test_cron_trigger_3():
    trigger = CronTrigger(year='2009', month='2', hour='8-10')
    eq_(repr(trigger), "<CronTrigger (year='2009', month='2', hour='8-10')>")
    start_date = datetime(2009, 1, 1)
    correct_next_date = datetime(2009, 2, 1, 8)
    eq_(trigger.get_next_fire_time(start_date), correct_next_date)