def setUp(self): self.now = timezone.now() self.member = UserFactory() self.group = GroupFactory(members=[self.member]) self.place = PlaceFactory(group=self.group) self.series = PickupDateSeriesFactory(max_collectors=3, place=self.place)
def setUp(self): self.member = UserFactory() self.group = GroupFactory(members=[self.member]) self.place = PlaceFactory(group=self.group) self.pickup = PickupDateFactory(place=self.place) self.pickup_url = '/api/pickup-dates/{}/'.format(self.pickup.id) self.series = PickupDateSeriesFactory(place=self.place) self.series_url = '/api/pickup-date-series/{}/'.format(self.series.id)
def setUp(self): self.now = timezone.now() self.url = '/api/places/' self.member = UserFactory() self.group = GroupFactory(members=[self.member]) self.place = PlaceFactory(group=self.group) self.place_url = self.url + str(self.place.id) + '/' self.series = PickupDateSeriesFactory(max_collectors=3, place=self.place)
def setUp(self): self.url = '/api/pickup-date-series/' self.series = PickupDateSeriesFactory() self.series_url = '/api/pickup-date-series/{}/'.format(self.series.id) self.non_member = UserFactory() self.series_data = { 'place': self.series.place.id, 'rule': 'FREQ=WEEKLY', 'start_date': timezone.now() }
def setUp(self): super().setUp() self.member = UserFactory() self.group = GroupFactory(members=[self.member]) self.place = PlaceFactory(group=self.group) # Create far in the future to generate no pickup dates # They would lead to interfering websocket messages self.series = PickupDateSeriesFactory(place=self.place, start_date=timezone.now() + relativedelta(months=2))
def test_create_all_pickup_dates_inactive_places(self): self.place.status = PlaceStatus.ARCHIVED.value self.place.save() start_date = self.place.group.timezone.localize(datetime.now().replace(2017, 3, 18, 15, 0, 0, 0)) PickupDateSeriesFactory(place=self.place, start_date=start_date) PickupDate.objects.all().delete() PickupDateSeries.objects.update_pickups() self.assertEqual(PickupDate.objects.count(), 0)
def setUp(self): self.url = '/api/pickup-dates/' # pickup date for group with one member and one place self.member = UserFactory() self.group = GroupFactory(members=[self.member]) self.place = PlaceFactory(group=self.group) self.pickup = PickupDateFactory(place=self.place) # and another place + group + pick-update self.group2 = GroupFactory(members=[self.member]) self.place2 = PlaceFactory(group=self.group2) self.pickup2 = PickupDateFactory(place=self.place2) # a pickup date series self.series = PickupDateSeriesFactory(place=self.place) # another pickup date series self.series2 = PickupDateSeriesFactory(place=self.place)
def test_daylight_saving_time_to_winter(self): start_date = self.place.group.timezone.localize(datetime.now().replace(2016, 10, 22, 15, 0, 0, 0)) before_dst_switch = timezone.now().replace(2016, 10, 22, 4, 40, 13) with freeze_time(before_dst_switch, tick=True): series = PickupDateSeriesFactory(place=self.place, start_date=start_date) expected_dates = [] for month, day in [(10, 22), (10, 29), (11, 5), (11, 12)]: expected_dates.append(self.place.group.timezone.localize(datetime(2016, month, day, 15, 0))) for actual_date, expected_date in zip(PickupDate.objects.filter(series=series), expected_dates): self.assertEqual(actual_date.date.start, expected_date)
def test_delete(self): now = timezone.now() two_weeks_ago = now - relativedelta(weeks=2) with freeze_time(two_weeks_ago, tick=True): series = PickupDateSeriesFactory(place=self.place, start_date=two_weeks_ago) pickup_dates = series.pickup_dates.all() past_date_count = pickup_dates.filter(date__startswith__lt=now).count() self.assertGreater(pickup_dates.count(), 2) series.delete() upcoming_pickups = PickupDate.objects.filter(date__startswith__gte=now, is_disabled=False) self.assertEqual(upcoming_pickups.count(), 0, upcoming_pickups) self.assertEqual(PickupDate.objects.filter(date__startswith__lt=now).count(), past_date_count)
def setUp(self): self.series = PickupDateSeriesFactory()