コード例 #1
0
 def test_sched_calc_5(self):
     """11 months since last run"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Yearly',
                     email_subject='nosend', time=nowish, start_date=d.today()-relativedelta(months=11),
                     last_scheduled_run=dt_today-relativedelta(months=11))
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #2
0
 def test_sched_calc_10(self):
     """1 year after start date"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Yearly',
                     email_subject='send', time=nowish, start_date=d.today(),
                     last_scheduled_run=dt_today-relativedelta(months=12))
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #3
0
 def test_sched_calc_4(self):
     """25 days after last run"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Monthly',
                     email_subject='nosend', time=nowish, start_date=d.today()-relativedelta(days=25),
                     last_scheduled_run=dt_today-relativedelta(days=25))
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #4
0
 def test_sched_calc_9(self):
     """7 days after last run"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Weekly',
                     email_subject='send', time=nowish, start_date=d.today(),
                     last_scheduled_run=dt_today-relativedelta(days=7))
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #5
0
 def test_sched_calc_6(self):
     """1 year after start date, but before time"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Yearly',
                     email_subject='nosend', time=(nowish_w_dt + relativedelta(hours=2)).time(), 
                     start_date=d.today(),
                     last_scheduled_run=dt_today-relativedelta(months=13))
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #6
0
 def test_sched_calc_11(self):
     """Next month on same day"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Monthly',
                     email_subject='send_feb1', time=datetime.time(0, 0),
                     start_date=d(d.today().year, 1, 1),
                     last_scheduled_run=dt_today-relativedelta(days=25))
     sched.save()
     pretend_today_is = dt(d.today().year, 2, 1)
     self.assertTrue(sched.should_send(pretend_today_is))
コード例 #7
0
 def test_sched_calc_7(self):
     """No prior runs"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Daily',
                          email_subject='send',
                          time=nowish,
                          start_date=d.today())
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #8
0
 def test_sched_calc_2(self):
     """6 days since last run"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Weekly',
                          email_subject='nosend',
                          time=nowish,
                          start_date=d.today(),
                          last_scheduled_run=dt_today -
                          relativedelta(days=6))
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #9
0
 def test_sched_calc_13(self):
     """25 days after last run but day and month are correct"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Monthly',
                          email_subject='send',
                          time=nowish,
                          start_date=d.today(),
                          last_scheduled_run=dt_today -
                          relativedelta(days=25))
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #10
0
 def test_sched_calc_12(self):
     """11 months since last run but day and month are right"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Yearly',
                          email_subject='send',
                          time=nowish,
                          start_date=d.today(),
                          last_scheduled_run=dt_today -
                          relativedelta(months=11))
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #11
0
 def test_sched_calc_8(self):
     """24.5 hours after last run"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Daily',
                          email_subject='send',
                          time=nowish,
                          start_date=d.today(),
                          last_scheduled_run=dt_today -
                          relativedelta(minutes=1470))
     sched.save()
     self.assertTrue(sched.should_send())
コード例 #12
0
 def test_sched_calc_6(self):
     """1 year after start date, but before time"""
     sched = Subscription(
         send_to=self.dummy_user,
         report=self.report,
         frequency='Yearly',
         email_subject='nosend',
         time=(nowish_w_dt + relativedelta(hours=2)).time(),
         start_date=d.today(),
         last_scheduled_run=dt_today - relativedelta(months=13))
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #13
0
 def test_sched_calc_3(self):
     """before start date"""
     sched = Subscription(
         send_to=self.dummy_user,
         report=self.report,
         frequency='Monthly',
         email_subject='nosend',
         time=nowish,
         start_date=d.today() + relativedelta(days=2),
     )
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #14
0
 def test_sched_calc_11(self):
     """Next month on same day"""
     sched = Subscription(send_to=self.dummy_user,
                          report=self.report,
                          frequency='Monthly',
                          email_subject='send_feb1',
                          time=datetime.time(0, 0),
                          start_date=d(d.today().year, 1, 1),
                          last_scheduled_run=dt_today -
                          relativedelta(days=25))
     sched.save()
     pretend_today_is = dt(d.today().year, 2, 1)
     self.assertTrue(sched.should_send(pretend_today_is))
コード例 #15
0
 def test_sched_calc_3(self):
     """before start date"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Monthly',
                     email_subject='nosend', time=nowish, start_date=d.today() + relativedelta(days=2),)
     sched.save()
     self.assertFalse(sched.should_send())
コード例 #16
0
 def test_sched_calc_7(self):
     """No prior runs"""
     sched = Subscription(send_to=self.dummy_user, report=self.report, frequency='Daily',
                     email_subject='send', time=nowish, start_date=d.today())
     sched.save()
     self.assertTrue(sched.should_send())