def test_writes_stats(self, write_points): write_points() with group_timezone_at(self.group, hour=20): tonight = relativedelta(minutes=10) tomorrow = relativedelta(hours=10) [self.create_user_pickup(tonight) for _ in range(2)] [self.create_empty_pickup(tonight) for _ in range(3)] [self.create_not_full_pickup(tonight) for _ in range(4)] [self.create_user_pickup(tomorrow) for _ in range(5)] [self.create_empty_pickup(tomorrow) for _ in range(6)] [self.create_not_full_pickup(tomorrow) for _ in range(7)] daily_pickup_notifications() write_points.assert_called_with([{ 'measurement': 'karrot.email.pickup_notification', 'tags': { 'group': str(self.group.id), }, 'fields': { 'value': 1, 'tonight_user': 2, 'tonight_empty': 3, 'tonight_not_full': 4, 'tomorrow_user': 5, 'tomorrow_empty': 6, 'tomorrow_not_full': 7, } }])
def test_ignores_not_active_stores(self): with group_timezone_at(self.group, hour=20): self.create_empty_pickup(delta=relativedelta(minutes=10), store=self.declined_store) daily_pickup_notifications() self.assertEqual(len(mail.outbox), 0)
def test_does_not_send_at_other_times(self): with group_timezone_at(self.group, hour=21): self.create_empty_pickup(delta=relativedelta(minutes=10)) daily_pickup_notifications() self.assertEqual(len(mail.outbox), 0)
def test_does_not_send_if_no_pickups(self): with group_timezone_at(self.group, hour=20): daily_pickup_notifications() self.assertEqual(len(mail.outbox), 0)
def test_send_notification_email(self): with group_timezone_at(self.group, hour=20): self.create_empty_pickup(delta=relativedelta(minutes=10)) daily_pickup_notifications() self.assertEqual(len(mail.outbox), 1) self.assertIn(store_url(self.store), mail.outbox[0].body)
def test_ignores_deleted_pickups(self): with group_timezone_at(self.group, hour=20): self.create_deleted_pickup(delta=relativedelta(minutes=10)) daily_pickup_notifications() self.assertEqual(len(mail.outbox), 0)