Beispiel #1
0
 def test_invalid_types(self):
     for activity_type in (IncidentActivityType.CREATED,
                           IncidentActivityType.DETECTED):
         activity = create_incident_activity(self.incident, activity_type)
         send_subscriber_notifications(activity.id)
         self.send_async.assert_not_called()  # NOQA
         self.send_async.reset_mock()
Beispiel #2
0
    def test_simple(self):
        activity = create_incident_activity(
            self.incident,
            IncidentActivityType.COMMENT,
            user=self.user,
            comment='hello',
        )
        send_subscriber_notifications(activity.id)
        # User shouldn't receive an email for their own activity
        self.send_async.assert_not_called()  # NOQA

        self.send_async.reset_mock()
        non_member_user = self.create_user(email='*****@*****.**')
        subscribe_to_incident(activity.incident, non_member_user)

        member_user = self.create_user(email='*****@*****.**')
        self.create_member([self.team],
                           user=member_user,
                           organization=self.organization)
        subscribe_to_incident(activity.incident, member_user)
        send_subscriber_notifications(activity.id)
        self.send_async.assert_called_once_with([member_user.email])
        assert not IncidentSubscription.objects.filter(
            incident=activity.incident,
            user=non_member_user,
        ).exists()
        assert IncidentSubscription.objects.filter(
            incident=activity.incident,
            user=member_user,
        ).exists()