예제 #1
0
 def setUp(self):
     self.now = timezone.pytz.timezone('Atlantic/Azores').localize(
         timezone.datetime(2016, 1, 2, 11, 12))
     self.earlier_timeslot = TimeSlotFactory(
         start_at=self.now + relativedelta(hours=-2),
         end_at=self.now + relativedelta(hours=-1))
     self.now_timeslot = TimeSlotFactory(
         start_at=self.now + relativedelta(hours=-0.5),
         end_at=self.now + relativedelta(hours=+0.5))
     self.later_timeslot = TimeSlotFactory(
         start_at=self.now + relativedelta(hours=+1),
         end_at=self.now + relativedelta(hours=+2))
예제 #2
0
    def test_includes_a_timeslot_which_is_starting_now(self):
        timeslot = TimeSlotFactory(start_at=self.now,
                                   end_at=self.now + relativedelta(hours=+1))

        with freeze_time(self.now):
            queryset = TimeSlot.objects.current()

        self.assertIn(timeslot, queryset)
예제 #3
0
    def test_includes_a_timeslot_which_has_ended_now(self):
        timeslot = TimeSlotFactory(start_at=self.now + relativedelta(hours=-1),
                                   end_at=self.now)

        with freeze_time(self.now):
            queryset = TimeSlot.objects.past()

        self.assertIn(timeslot, queryset)
예제 #4
0
    def test_excludes_a_timeslot_which_ended_yesterday(self):
        timeslot = TimeSlotFactory(start_at=self.now +
                                   relativedelta(hours=-26),
                                   end_at=self.now + relativedelta(hours=-25))

        with freeze_time(self.now):
            queryset = TimeSlot.objects.current()

        self.assertNotIn(timeslot, queryset)
예제 #5
0
    def test_excludes_a_timeslot_which_starts_tomorrow(self):
        timeslot = TimeSlotFactory(start_at=self.now +
                                   relativedelta(hours=+24),
                                   end_at=self.now + relativedelta(hours=+25))

        with freeze_time(self.now):
            queryset = TimeSlot.objects.past()

        self.assertNotIn(timeslot, queryset)
예제 #6
0
    def test_excludes_a_timeslot_which_is_happening_now(self):
        timeslot = TimeSlotFactory(start_at=self.now +
                                   relativedelta(hours=-0.5),
                                   end_at=self.now + relativedelta(hours=+0.5))

        with freeze_time(self.now):
            queryset = TimeSlot.objects.past()

        self.assertNotIn(timeslot, queryset)