コード例 #1
0
ファイル: test_release.py プロジェクト: kinggggg/sentry
    def test_doesnt_generate_on_no_release(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={'version': 'a'},
            ))

        assert email.release is None
        assert not email.should_email()
コード例 #2
0
ファイル: test_release.py プロジェクト: alexm92/sentry
    def test_doesnt_generate_on_no_release(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={'version': 'a'},
            )
        )

        assert email.release is None
        assert not email.should_email()
コード例 #3
0
    def test_uses_default(self):
        user6 = self.create_user()
        self.create_member(user=user6,
                           organization=self.org,
                           teams=[self.team])

        UserOption.objects.set_value(user=user6,
                                     organization=None,
                                     key="deploy-emails",
                                     value=UserOptionValue.all_deploys)

        release = Release.objects.create(
            version="b" * 40,
            organization_id=self.project.organization_id,
            date_released=timezone.now(),
        )
        release.add_project(self.project)
        release.add_project(self.project2)
        deploy = Deploy.objects.create(release=release,
                                       organization_id=self.org.id,
                                       environment_id=self.environment.id)

        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    "version": release.version,
                    "deploy_id": deploy.id
                },
            ))

        # user3 and user 6 are included because they oped into all deploy emails
        # (one on an org level, one as their default)
        assert len(email.get_participants()) == 2

        assert email.get_participants() == {
            user6: GroupSubscriptionReason.deploy_setting,
            self.user3: GroupSubscriptionReason.deploy_setting,
        }

        context = email.get_context()
        assert context["environment"] == "production"
        assert context["repos"] == []

        user_context = email.get_user_context(user6)
        # make sure this only includes projects user has access to
        assert len(user_context["projects"]) == 1
        assert user_context["projects"][0][0] == self.project

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 2

        sent_email_addresses = {msg.to[0] for msg in mail.outbox}

        assert sent_email_addresses == {self.user3.email, user6.email}
コード例 #4
0
ファイル: test_release.py プロジェクト: wrndlb/sentry
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    'version': self.release.version,
                    'deploy_id': self.deploy.id,
                },
            ))

        with self.feature('workflow:release-emails'):
            assert email.get_participants() == {
                self.user: GroupSubscriptionReason.committed,
            }

            context = email.get_context()
            assert context['environment'] == 'production'
            assert context['repos'][0]['commits'] == [
                (self.commit, self.user),
                (self.commit2, self.user2),
            ]
            user_context = email.get_user_context(self.user)
            # make sure this only includes projects user has access to
            assert len(user_context['projects']) == 1
            assert user_context['projects'][0][0] == self.project

            with self.tasks():
                email.send()

            assert len(mail.outbox) == 1
            msg = mail.outbox[-1]
            assert msg.to == [self.user.email]
コード例 #5
0
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    "version": self.release.version,
                    "deploy_id": self.deploy.id
                },
            ))
        # user is included because they committed
        # user2 committed but isn't in a team associated with the project.
        # user3 is included because they oped into all deploy emails
        # user4 committed but isn't included because they opted out of all deploy emails
        # for that org -- also tests to make sure org overrides default preference
        # user5 committed with another email address and is still included.

        assert len(email.get_participants()) == 3

        assert email.get_participants() == {
            self.user: GroupSubscriptionReason.committed,
            self.user3: GroupSubscriptionReason.deploy_setting,
            self.user5: GroupSubscriptionReason.committed,
        }

        context = email.get_context()
        assert context["environment"] == "production"
        assert context["repos"][0]["commits"] == [
            (self.commit, self.user),
            (self.commit2, self.user2),
            (self.commit3, self.user4),
            (self.commit4, self.user5),
        ]

        user_context = email.get_user_context(self.user)
        # make sure this only includes projects user has access to
        assert len(user_context["projects"]) == 1
        assert user_context["projects"][0][0] == self.project

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 3

        sent_email_addresses = {msg.to[0] for msg in mail.outbox}

        assert sent_email_addresses == {
            self.user.email, self.user3.email, self.user5.email
        }
コード例 #6
0
ファイル: test_release.py プロジェクト: sashahilton00/sentry
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    'version': self.release.version,
                    'deploy_id': self.deploy.id,
                },
            )
        )

        with self.feature('workflow:release-emails'):
            assert email.get_participants() == {
                self.user: GroupSubscriptionReason.committed,
            }

            context = email.get_context()
            assert context['environment'] == 'production'
            assert context['repos'][0]['commits'] == [
                (self.commit, self.user),
                (self.commit2, self.user2),
            ]
            user_context = email.get_user_context(self.user)
            # make sure this only includes projects user has access to
            assert len(user_context['projects']) == 1
            assert user_context['projects'][0][0] == self.project

            with self.tasks():
                email.send()

            assert len(mail.outbox) == 1
            msg = mail.outbox[-1]
            assert msg.to == [self.user.email]
コード例 #7
0
    def test_no_committers(self):
        release = Release.objects.create(
            version='b' * 40,
            organization_id=self.project.organization_id,
            date_released=timezone.now(),
        )
        release.add_project(self.project)
        release.add_project(self.project2)
        deploy = Deploy.objects.create(
            release=release,
            organization_id=self.org.id,
            environment_id=self.environment.id,
        )

        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    'version': release.version,
                    'deploy_id': deploy.id,
                },
            ))

        # only user3 is included because they oped into all deploy emails
        assert len(email.get_participants()) == 1

        assert email.get_participants() == {
            self.user3: GroupSubscriptionReason.deploy_setting,
        }

        context = email.get_context()
        assert context['environment'] == 'production'
        assert context['repos'] == []

        user_context = email.get_user_context(self.user)
        # make sure this only includes projects user has access to
        assert len(user_context['projects']) == 1
        assert user_context['projects'][0][0] == self.project

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 1

        sent_email_addresses = {msg.to[0] for msg in mail.outbox}

        assert sent_email_addresses == {self.user3.email}
コード例 #8
0
ファイル: test_release.py プロジェクト: alexm92/sentry
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={'version': self.release.version},
            )
        )

        with self.feature('workflow:release-emails'):
            assert email.get_participants() == {
                self.user: GroupSubscriptionReason.committed,
            }

            context = email.get_context()
            assert context['commit_list'] == [self.commit, self.commit2]

            with self.tasks():
                email.send()

            assert len(mail.outbox) == 1
            msg = mail.outbox[-1]
            assert msg.to == [self.user.email]
コード例 #9
0
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    'version': self.release.version,
                    'deploy_id': self.deploy.id,
                },
            ))
        # user is included because they committed
        # user2 committed but isn't in a team associated with the project.
        # user3 is included because they oped into all deploy emails
        # user4 commited but isn't included because they opted out of all deploy emails
        assert len(email.get_participants()) == 2

        assert email.get_participants() == {
            self.user: GroupSubscriptionReason.committed,
            self.user3: GroupSubscriptionReason.deploy_setting,
        }

        context = email.get_context()
        assert context['environment'] == 'production'
        assert context['repos'][0]['commits'] == [
            (self.commit, self.user),
            (self.commit2, self.user2),
            (self.commit3, self.user4),
        ]
        user_context = email.get_user_context(self.user)
        # make sure this only includes projects user has access to
        assert len(user_context['projects']) == 1
        assert user_context['projects'][0][0] == self.project

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 2
        msg = mail.outbox[0]
        assert msg.to == [self.user.email] or msg.to == [self.user3.email]

        msg2 = mail.outbox[1]
        assert msg2.to == [self.user.email] or msg2.to == [self.user3.email]

        assert msg.to != msg2.to
コード例 #10
0
ファイル: test_release.py プロジェクト: alexandrul/sentry
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={
                    'version': self.release.version,
                    'deploy_id': self.deploy.id,
                },
            )
        )
        # user is included because they committed
        # user2 committed but isn't in a team associated with the project.
        # user3 is included because they oped into all deploy emails
        # user4 committed but isn't included because they opted out of all deploy emails
        # user5 committed with another email address and is still included.

        assert len(email.get_participants()) == 3

        assert email.get_participants() == {
            self.user: GroupSubscriptionReason.committed,
            self.user3: GroupSubscriptionReason.deploy_setting,
            self.user5: GroupSubscriptionReason.committed,
        }

        context = email.get_context()
        assert context['environment'] == 'production'
        assert context['repos'][0]['commits'] == [
            (self.commit, self.user),
            (self.commit2, self.user2),
            (self.commit3, self.user4),
            (self.commit4, self.user5),
        ]

        user_context = email.get_user_context(self.user)
        # make sure this only includes projects user has access to
        assert len(user_context['projects']) == 1
        assert user_context['projects'][0][0] == self.project

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 3

        sent_email_addresses = {msg.to[0] for msg in mail.outbox}

        assert sent_email_addresses == {self.user.email, self.user3.email, self.user5.email}
コード例 #11
0
    def test_simple(self):
        email = ReleaseActivityEmail(
            Activity(
                project=self.project,
                user=self.user,
                type=Activity.RELEASE,
                data={'version': self.release.version},
            ))

        assert email.get_participants() == {
            self.user: GroupSubscriptionReason.committed,
        }

        context = email.get_context()
        assert context['commit_list'] == [self.commit, self.commit2]

        with self.tasks():
            email.send()

        assert len(mail.outbox) == 1
        msg = mail.outbox[-1]
        assert msg.to == [self.user.email]