コード例 #1
0
 def testDailyReportLenientWindow(self):
     ReportNotification(hour=12, minute=0, interval='daily').save()
     self._check('daily', datetime(2014, 10, 31, 12, 5), 1)  # lenient window
     # but not too lenient
     self.assertRaises(
         ValueError,
         lambda: list(get_scheduled_report_ids('daily', end_datetime=datetime(2014, 10, 31, 12, 6)))
     )
コード例 #2
0
 def testDailyReportLenientWindow(self):
     ReportNotification(hour=12, minute=0, interval='daily').save()
     self._check('daily', datetime(2014, 10, 31, 12, 5),
                 1)  # lenient window
     # but not too lenient
     self.assertRaises(
         ValueError, lambda: list(
             get_scheduled_report_ids(
                 'daily', end_datetime=datetime(2014, 10, 31, 12, 6))))
コード例 #3
0
 def _check(self, period, as_of, count):
     # get_scheduled_report_ids relies on end_datetime
     # being strictly greater than start_datetime
     # for tests targeting an exact minute mark,
     # we need to add a small amount to make it after.
     # This is a reasonable thing to do because in production,
     # it'll always run a short time after the periodic task is fired
     as_of += timedelta(microseconds=1)
     self.assertEqual(count, len(list(get_scheduled_report_ids(period, end_datetime=as_of))))
コード例 #4
0
 def _check(self, period, as_of, count):
     # get_scheduled_report_ids relies on end_datetime
     # being strictly greater than start_datetime
     # for tests targeting an exact minute mark,
     # we need to add a small amount to make it after.
     # This is a reasonable thing to do because in production,
     # it'll always run a short time after the periodic task is fired
     as_of += timedelta(microseconds=1)
     self.assertEqual(
         count,
         len(list(get_scheduled_report_ids(period, end_datetime=as_of))))
コード例 #5
0
 def testDefaultValue(self):
     now = datetime.utcnow()
     # This line makes sure that the date of the ReportNotification is an increment of 15 minutes
     ReportNotification(hour=now.hour,
                        minute=(now.minute // 15) * 15,
                        interval='daily').save()
     if now.minute % 15 <= 5:
         self._check('daily', None, 1)
     else:
         self.assertRaises(
             ValueError,
             lambda: list(get_scheduled_report_ids('daily', None)))
コード例 #6
0
ファイル: tasks.py プロジェクト: lskdev/commcare-hq
def monthly_reports():
    for report_id in get_scheduled_report_ids('monthly'):
        send_delayed_report(report_id)
コード例 #7
0
ファイル: tasks.py プロジェクト: lskdev/commcare-hq
def weekly_reports():
    for report_id in get_scheduled_report_ids('weekly'):
        send_delayed_report(report_id)
コード例 #8
0
ファイル: tasks.py プロジェクト: lskdev/commcare-hq
def daily_reports():
    for report_id in get_scheduled_report_ids('daily'):
        send_delayed_report(report_id)
コード例 #9
0
 def _check(self, period, as_of, count):
     self.assertEqual(count,
                      len(list(get_scheduled_report_ids(period, as_of))))