예제 #1
0
    def test_update_comment(self):
        org = self.organization

        self.user.name = "Sentry Admin"
        self.user.save()
        self.login_as(self.user)

        integration = Integration.objects.create(provider="jira",
                                                 name="Example Jira")
        integration.add_organization(org, self.user)
        installation = integration.get_installation(org.id)

        group_note = Mock()
        comment = "hello world\nThis is a comment.\n\n\n    I've changed it"
        group_note.data = {}
        group_note.data["text"] = comment
        group_note.data["external_id"] = "123"
        with mock.patch.object(MockJiraApiClient,
                               "update_comment") as mock_update_comment:

            def get_client():
                return MockJiraApiClient()

            with mock.patch.object(installation, "get_client", get_client):
                installation.update_comment(1, self.user.id, group_note)
                assert mock_update_comment.call_args[0] == (
                    1,
                    "123",
                    "Sentry Admin wrote:\n\n{quote}%s{quote}" % comment,
                )
예제 #2
0
    def test_adds_type(self):
        sub = self.create_subscription(QuerySubscription.Status.CREATING)
        with patch("sentry.snuba.tasks._snuba_pool") as pool:
            resp = Mock()
            resp.status = 202
            resp.data = json.dumps({"subscription_id": "123"})
            pool.urlopen.return_value = resp

            create_subscription_in_snuba(sub.id)
            request_body = json.loads(pool.urlopen.call_args[1]["body"])
            assert ["type", "=", "error"] in request_body["conditions"]
예제 #3
0
    def test_create_comment(self, mock_update_work_item):
        self.assert_installation()
        integration = Integration.objects.get(provider="vsts")
        installation = integration.get_installation(self.organization.id)

        self.user.name = "Sentry Admin"
        self.user.save()

        comment_text = "hello world\nThis is a comment.\n\n\n    Glad it's quoted"
        comment = Mock()
        comment.data = {"text": comment_text}

        installation.create_comment(1, self.user.id, comment)

        assert (mock_update_work_item.call_args[1]["comment"] ==
                "Sentry Admin wrote:\n\n<blockquote>%s</blockquote>" %
                comment_text)