Example #1
0
 def test_should_return_true_for_reminder_before_deadline_type_if_today_is_on_weekend(
         self):
     # Case where deadline is in next week, but reminder is scheduled today
     today = date(2011, 9, 11)
     reminder = Reminder(reminder_mode=ReminderMode.BEFORE_DEADLINE, day=2)
     deadline = Deadline(frequency=Week(2), mode="That")
     self.assertTrue(reminder.should_be_send_on(deadline, today))
Example #2
0
 def test_should_return_true_for_reminder_after_deadline_type_if_today_is_three_days_after_deadline_2(
         self):
     # next week
     today = date(2011, 9, 13)
     reminder = Reminder(reminder_mode=ReminderMode.AFTER_DEADLINE, day=3)
     deadline = Deadline(frequency=Week(6), mode="That")
     self.assertTrue(reminder.should_be_send_on(deadline, today))
Example #3
0
 def test_should_return_false_for_reminder_before_deadline_type_if_today_is_not_two_days_before_deadline(
         self):
     today = date(2011, 9, 9)
     # Sunday deadline
     reminder = Reminder(reminder_mode=ReminderMode.BEFORE_DEADLINE, day=1)
     deadline = Deadline(frequency=Week(7), mode="That")
     self.assertFalse(reminder.should_be_send_on(deadline, today))
Example #4
0
 def test_should_return_true_for_reminder_before_deadline_type_if_today_is_two_days_before_following_deadline(
         self):
     # same week
     today = date(2011, 9, 9)
     reminder = Reminder(reminder_mode=ReminderMode.BEFORE_DEADLINE, day=2)
     deadline = Deadline(frequency=Week(7), mode="Following")
     self.assertTrue(reminder.should_be_send_on(deadline, today))
Example #5
0
 def test_should_return_next_deadline_date_for_current_week_for_day3(self):
     deadline = Deadline(frequency=Week(3), mode="That")
     self.assertEqual(date(2011, 9, 21), deadline.next(date(2011, 9, 19)))
Example #6
0
 def test_should_return_description_of_weekly_deadline_in_following_mode(
         self):
     deadline = Deadline(frequency=Week(5), mode="Following")
     self.assertEqual('Friday of the Following Week',
                      deadline.description())
Example #7
0
 def test_should_return_description_of_weekly_deadline_in_that_mode(self):
     deadline = Deadline(frequency=Week(1), mode="That")
     self.assertEqual('Monday of the Week', deadline.description())
Example #8
0
 def test_should_get_applicapable_frequency_only_if_given_date_is_a_weekly_deadline(
         self):
     deadline = Deadline(frequency=Week(2), mode="Following")
     self.assertRaises(NotADeadLine,
                       deadline.get_applicable_frequency_period_for,
                       date(2011, 9, 14))
Example #9
0
 def test_should_retun_frequency_period_for_a_given_deadline_when_deadline_frequency_is_week_and_mode_is_following_1(
         self):
     deadline = Deadline(frequency=Week(2), mode="Following")
     self.assertEqual(
         (date(2011, 9, 5), date(2011, 9, 11)),
         deadline.get_applicable_frequency_period_for(date(2011, 9, 13)))
Example #10
0
 def test_should_return_current_deadline_date_for_this_week_for_following_deadline_for_today_on_deadline(
         self):
     deadline = Deadline(frequency=Week(6), mode="Following")
     self.assertEqual(date(2011, 9, 17), deadline.current(date(2011, 9,
                                                               17)))
Example #11
0
 def _frequency(self):
     if self.reminder_and_deadline.get('frequency_period') == 'month':
         return Month(int(self.reminder_and_deadline.get('deadline_month')))
     if self.reminder_and_deadline.get('frequency_period') == 'week':
         return Week(int(self.reminder_and_deadline.get('deadline_week')))
Example #12
0
 def test_should_return_next_deadline_for_weekly_frequency_for_date_after_deadline(
         self):
     week = Week(3)
     self.assertEqual(date(2011, 9, 14),
                      week.next_deadline_date(date(2011, 9, 9)))
Example #13
0
 def test_should_return_current_deadline_for_weekly_frequency_for_date_on_deadline(
         self):
     week = Week(3)
     self.assertEqual(date(2011, 9, 7),
                      week.current_deadline_date(date(2011, 9, 7)))
Example #14
0
 def test_should_return_false_for_reminder_on_deadline_type_if_today_is_not_on_deadline(
         self):
     today = date(2011, 9, 10)
     reminder = Reminder(reminder_mode=ReminderMode.ON_DEADLINE)
     deadline = Deadline(frequency=Week(5), mode="That")
     self.assertFalse(reminder.should_be_send_on(deadline, today))
Example #15
0
 def test_should_return_next_deadline_date_for_current_week_and_asof_post_deadline_day(
         self):
     deadline = Deadline(frequency=Week(6), mode="That")
     self.assertEqual(None, deadline.next(date(2011, 9, 18)))
Example #16
0
 def test_should_return_next_deadline_date_for_following_week_and_asof_post_deadline_day(
         self):
     deadline = Deadline(frequency=Week(6), mode="Following")
     self.assertEqual(date(2011, 9, 24), deadline.next(date(2011, 9, 18)))
Example #17
0
 def test_should_return_current_deadline_date_for_this_week_for_that_deadline_for_day3_for_deadline_on_different_day(
         self):
     deadline = Deadline(frequency=Week(3), mode="That")
     self.assertEqual(date(2011, 9, 21), deadline.current(date(2011, 9,
                                                               19)))
Example #18
0
 def test_should_return_current_deadline_date_for_this_week_for_that_deadline(
         self):
     deadline = Deadline(frequency=Week(6), mode="That")
     self.assertEqual(date(2011, 9, 17), deadline.current(date(2011, 9,
                                                               15)))
Example #19
0
 def test_should_retun_frequency_period_for_a_given_deadline_when_deadline_frequency_is_week_and_mode_is_that(
         self):
     deadline = Deadline(frequency=Week(5), mode="That")
     self.assertEqual(
         (date(2011, 9, 12), date(2011, 9, 18)),
         deadline.get_applicable_frequency_period_for(date(2011, 9, 16)))