Exemple #1
0
    def test_no_summary_email_if_no_activity_in_group(self, write_points):
        group = GroupFactory(members=[VerifiedUserFactory()])

        with freeze_time(
                datetime.datetime(2018, 8, 19, 6, 0, 0, tzinfo=pytz.utc)):
            write_points.reset_mock()
            mail.outbox = []
            send_summary_emails()

        self.assertEqual(len(mail.outbox), 0)
        write_points.assert_called_with([{
            'measurement': 'karrot.email.group_summary',
            'tags': {
                'group': str(group.id),
                'group_status': 'active',
            },
            'fields': {
                'value': 1,
                'new_user_count': 0,
                'email_recipient_count': 0,
                'feedback_count': 0,
                'activities_missed_count': 0,
                'message_count': 0,
                'activities_done_count': 0,
                'has_activity': False,
            },
        }])
    def test_collects_stats(self, write_points):
        group = GroupFactory()

        with freeze_time(
                datetime.datetime(2018, 8, 19, 6, 0, 0, tzinfo=pytz.utc)):
            self.make_activity_in_group(group)
            write_points.reset_mock()
            mail.outbox = []
            send_summary_emails()

        self.assertEqual(len(mail.outbox), self.new_user_count)
        write_points.assert_called_with([{
            'measurement': 'karrot.email.group_summary',
            'tags': {
                'group': str(group.id),
                'group_status': 'active',
            },
            'fields': {
                'value': 1,
                'new_user_count': self.new_user_count,
                'email_recipient_count': self.new_user_count,
                'feedback_count': self.feedback_count,
                'pickups_missed_count': self.pickups_missed_count,
                'message_count': self.message_count,
                'pickups_done_count': self.pickups_done_count,
                'has_activity': True,
            },
        }])
Exemple #3
0
 def test_summary_emails_do_not_send_at_other_times(self):
     group = GroupFactory(timezone=pytz.timezone('Europe/Berlin'))
     # 6am UTC is 8am in this timezone
     with timezone.override(timezone.utc), freeze_time(
             datetime.datetime(2018, 8, 19, 7, 0, 0, tzinfo=pytz.utc)):
         self.make_activity_in_group(group)
         mail.outbox = []
         send_summary_emails()
         self.assertEqual(len(mail.outbox), 0)