Beispiel #1
0
    def test_get_participants(self):
        organization = self.create_organization(owner=self.create_user())
        team = self.create_team(organization=organization)
        project = self.create_project(organization=organization, team=team)
        group = self.create_group(project=project)

        actor = self.create_user()
        other = self.create_user()

        for user in (actor, other):
            self.create_member([team], user=user, organization=organization)
            GroupSubscription.objects.subscribe(group, user)

        email = ActivityEmail(
            Activity(
                project=group.project,
                group=group,
                user=actor,
            )
        )

        assert email.get_participants() == set([other])

        UserOption.objects.set_value(
            user=actor,
            project=None,
            key='self_notifications',
            value='1'
        )

        assert email.get_participants() == set([actor, other])
Beispiel #2
0
    def test_get_participants_without_actor(self):
        group, (user, ) = self.get_fixture_data(1)

        email = ActivityEmail(Activity(
            project=group.project,
            group=group,
        ))

        assert set(email.get_participants()) == set([user])
Beispiel #3
0
    def test_get_participants(self):
        group, (actor, other) = self.get_fixture_data(2)

        email = ActivityEmail(Activity(project=group.project, group=group, user=actor))

        assert set(email.get_participants()) == set([other])

        UserOption.objects.set_value(user=actor, key="self_notifications", value="1")

        assert set(email.get_participants()) == set([actor, other])
Beispiel #4
0
    def test_get_subject(self):
        group, (user, ) = self.get_fixture_data(1)

        email = ActivityEmail(Activity(project=group.project, group=group))

        with mock.patch(
                "sentry.models.ProjectOption.objects.get_value") as get_value:
            get_value.side_effect = (
                lambda project, key, default=None: "[Example prefix] "
                if key == "mail:subject_prefix" else default)
            assert email.get_subject_with_prefix().startswith(
                "[Example prefix] ")