Beispiel #1
0
    def test_notify_failure(self):
        n = NotificationPlugin()
        n.slug = 'slack'

        def hook(*a, **kw):
            raise HTTPError('401 Unauthorized')

        event = self.create_event()
        notification = Notification(event)

        n.notify_users = hook
        assert n.notify(notification) is False
Beispiel #2
0
 def test_notification_plugin(self):
     plugin_enabled.send(plugin=NotificationPlugin(),
                         project=self.project,
                         user=self.owner,
                         sender=type(self.project))
     feature_complete = FeatureAdoption.objects.get_by_slug(
         organization=self.organization, slug="notification_integration")
     assert feature_complete
Beispiel #3
0
    def test_notify_failure(self):
        errors = (
            ApiError('The server is sad'),
            SSLError('[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)'),
            HTTPError('A bad response'),
            PluginError('A plugin is sad'),
        )
        for err in errors:
            n = NotificationPlugin()
            n.slug = 'slack'

            def hook(*a, **kw):
                raise err
            event = self.create_event()
            notification = Notification(event)

            n.notify_users = hook
            assert n.notify(notification) is False
Beispiel #4
0
    def test_notify_failure(self):
        errors = (
            ApiError('The server is sad'),
            SSLError('[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)'),
            HTTPError('A bad response'),
        )
        for err in errors:
            n = NotificationPlugin()
            n.slug = 'slack'

            def hook(*a, **kw):
                raise err

            event = self.create_event()
            notification = Notification(event)

            n.notify_users = hook
            assert n.notify(notification) is False
Beispiel #5
0
 def test_notification_added(self):
     plugin_enabled.send(plugin=NotificationPlugin(),
                         project=self.project,
                         user=self.user,
                         sender=type(NotificationPlugin))
     task = OrganizationOnboardingTask.objects.get(
         organization=self.organization,
         task=OnboardingTask.NOTIFICATION_SERVICE,
         status=OnboardingTaskStatus.COMPLETE,
     )
     assert task is not None
Beispiel #6
0
    def test_onboarding_complete(self):
        now = timezone.now()
        user = self.create_user(email="*****@*****.**")
        project = self.create_project(first_event=now)
        second_project = self.create_project(first_event=now)
        second_event = self.create_event(project=second_project,
                                         platform="python",
                                         message="python error message")
        event = self.create_full_event(project=project)
        member = self.create_member(organization=self.organization,
                                    teams=[self.team],
                                    user=user)

        event_processed.send(project=project,
                             event=event,
                             sender=type(project))
        project_created.send(project=project, user=user, sender=type(project))
        project_created.send(project=second_project,
                             user=user,
                             sender=type(second_project))

        first_event_received.send(project=project,
                                  event=event,
                                  sender=type(project))
        first_event_received.send(project=second_project,
                                  event=second_event,
                                  sender=type(second_project))
        member_joined.send(member=member,
                           organization=self.organization,
                           sender=type(member))
        plugin_enabled.send(
            plugin=IssueTrackingPlugin(),
            project=project,
            user=user,
            sender=type(IssueTrackingPlugin),
        )
        issue_tracker_used.send(
            plugin=IssueTrackingPlugin(),
            project=project,
            user=user,
            sender=type(IssueTrackingPlugin),
        )
        plugin_enabled.send(plugin=NotificationPlugin(),
                            project=project,
                            user=user,
                            sender=type(NotificationPlugin))

        assert (OrganizationOption.objects.filter(
            organization=self.organization,
            key="onboarding:complete").count() == 1)
Beispiel #7
0
    def test_add_notification_referrer_param(self):
        n = NotificationPlugin()
        n.slug = 'slack'
        url = 'https://sentry.io/'
        assert n.add_notification_referrer_param(
            url) == url + '?referrer=' + n.slug

        url = 'https://sentry.io/?referrer=notslack'
        assert n.add_notification_referrer_param(
            url) == 'https://sentry.io/?referrer=slack'

        url = 'https://sentry.io/?utm_source=google'
        assert n.add_notification_referrer_param(
            url) == 'https://sentry.io/?referrer=slack&utm_source=google'

        n.slug = ''
        url = 'https://sentry.io/'
        assert n.add_notification_referrer_param(url) == 'https://sentry.io/'
Beispiel #8
0
    def test_add_notification_referrer_param(self):
        n = NotificationPlugin()
        n.slug = "slack"
        url = "https://sentry.io/"
        assert n.add_notification_referrer_param(url) == url + "?referrer=" + n.slug

        url = "https://sentry.io/?referrer=notslack"
        assert n.add_notification_referrer_param(url) == "https://sentry.io/?referrer=slack"

        url = "https://sentry.io/?utm_source=google"
        assert (
            n.add_notification_referrer_param(url)
            == "https://sentry.io/?referrer=slack&utm_source=google"
        )

        n.slug = ""
        url = "https://sentry.io/"
        assert n.add_notification_referrer_param(url) == "https://sentry.io/"
Beispiel #9
0
    def test_onboarding_complete(self):
        # Drop microsecond value for MySQL
        now = timezone.now().replace(microsecond=0)
        user = self.create_user(email='*****@*****.**')
        project = self.create_project(first_event=now)
        second_project = self.create_project(first_event=now)
        second_group = self.create_group(project=second_project,
                                         platform='python',
                                         message='python error message')
        event = self.create_full_event()
        member = self.create_member(organization=self.organization,
                                    teams=[self.team],
                                    user=user)

        event_processed.send(project=project,
                             group=self.group,
                             event=event,
                             sender=type(project))
        project_created.send(project=project, user=user, sender=type(project))
        project_created.send(project=second_project,
                             user=user,
                             sender=type(second_project))

        first_event_received.send(project=project,
                                  group=self.group,
                                  sender=type(project))
        first_event_received.send(project=second_project,
                                  group=second_group,
                                  sender=type(second_project))
        member_joined.send(member=member, sender=type(member))
        plugin_enabled.send(plugin=IssueTrackingPlugin(),
                            project=project,
                            user=user,
                            sender=type(IssueTrackingPlugin))
        issue_tracker_used.send(plugin=IssueTrackingPlugin(),
                                project=project,
                                user=user,
                                sender=type(IssueTrackingPlugin))
        plugin_enabled.send(plugin=NotificationPlugin(),
                            project=project,
                            user=user,
                            sender=type(NotificationPlugin))

        assert OrganizationOption.objects.filter(
            organization=self.organization,
            key="onboarding:complete").count() == 1
Beispiel #10
0
    def test_add_notification_referrer_param(self):
        n = NotificationPlugin()
        n.slug = 'slack'
        url = 'https://sentry.io/'
        assert n.add_notification_referrer_param(url) == url + '?referrer=' + n.slug

        url = 'https://sentry.io/?referrer=notslack'
        assert n.add_notification_referrer_param(url) == 'https://sentry.io/?referrer=slack'

        url = 'https://sentry.io/?utm_source=google'
        assert n.add_notification_referrer_param(
            url
        ) == 'https://sentry.io/?referrer=slack&utm_source=google'

        n.slug = ''
        url = 'https://sentry.io/'
        assert n.add_notification_referrer_param(url) == 'https://sentry.io/'