コード例 #1
0
 def test_invalid_action(self):
     with self.assertRaises(APIError):
         IssueLinkCreator.run(
             install=self.install,
             group=self.group,
             action='doop',
             uri='/link-issue',
             fields={},
         )
コード例 #2
0
 def test_invalid_action(self):
     with self.assertRaises(APIError):
         IssueLinkCreator.run(
             install=self.install,
             group=self.group,
             action="doop",
             uri="/link-issue",
             fields={},
             user=self.user,
         )
コード例 #3
0
 def test_invalid_action(self):
     with self.assertRaises(APIError):
         IssueLinkCreator.run(
             install=self.install,
             group=self.group,
             action='doop',
             uri='/link-issue',
             fields={},
             user=self.user,
         )
コード例 #4
0
    def test_creates_external_issue(self):
        fields = {
            "title": "An Issue",
            "description": "a bug was found",
            "assignee": "user-1"
        }

        responses.add(
            method=responses.POST,
            url="https://example.com/link-issue",
            json={
                "project": "ProjectName",
                "webUrl": "https://example.com/project/issue-id",
                "identifier": "issue-1",
            },
            status=200,
            content_type="application/json",
        )

        result = IssueLinkCreator.run(
            install=self.install,
            group=self.group,
            action="create",
            uri="/link-issue",
            fields=fields,
            user=self.user,
        )

        external_issue = PlatformExternalIssue.objects.all()[0]
        assert result == external_issue
        assert external_issue.web_url == "https://example.com/project/issue-id"
        assert external_issue.display_name == "ProjectName#issue-1"
コード例 #5
0
    def post(self, request, installation):
        if not features.has('organizations:sentry-apps',
                            installation.organization,
                            actor=request.user):
            return Response(status=404)

        group_id = request.DATA.get('groupId')
        if not group_id:
            return Response({'detail': 'groupId is required'}, status=400)

        try:
            group = Group.objects.get(
                id=group_id,
                project_id__in=Project.objects.filter(
                    organization_id=installation.organization_id, ))
        except Group.DoesNotExist:
            return Response(status=404)

        try:
            external_issue = IssueLinkCreator.run(
                install=installation,
                group=group,
                action=request.DATA.get('action'),
                fields=request.DATA.get('fields'),
                uri=request.DATA.get('uri'),
            )
        except Exception:
            return Response(
                {'error': 'Error communicating with Sentry App service'},
                status=400)

        return Response(serialize(external_issue))
コード例 #6
0
    def test_creates_external_issue(self):
        fields = {
            'title': 'An Issue',
            'description': 'a bug was found',
            'assignee': 'user-1',
        }

        responses.add(
            method=responses.POST,
            url='https://example.com/link-issue',
            json={
                'project': 'ProjectName',
                'webUrl': 'https://example.com/project/issue-id',
                'identifier': 'issue-1',
            },
            status=200,
            content_type='application/json',
        )

        result = IssueLinkCreator.run(
            install=self.install,
            group=self.group,
            action='create',
            uri='/link-issue',
            fields=fields,
            user=self.user,
        )

        external_issue = PlatformExternalIssue.objects.all()[0]
        assert result == external_issue
        assert external_issue.web_url == \
            'https://example.com/project/issue-id'
        assert external_issue.display_name == 'ProjectName#issue-1'
コード例 #7
0
    def post(self, request, installation):
        if not features.has('organizations:sentry-apps',
                            installation.organization,
                            actor=request.user):
            return Response(status=404)

        data = request.DATA.copy()

        if not set(['groupId', 'action', 'uri']).issubset(data.keys()):
            return Response(status=400)

        group_id = data.get('groupId')
        del data['groupId']

        try:
            group = Group.objects.get(
                id=group_id,
                project_id__in=Project.objects.filter(
                    organization_id=installation.organization_id, ))
        except Group.DoesNotExist:
            return Response(status=404)

        action = data['action']
        del data['action']

        uri = data.get('uri')
        del data['uri']

        try:
            external_issue = IssueLinkCreator.run(
                install=installation,
                group=group,
                action=action,
                fields=data,
                uri=uri,
                user=request.user,
            )
        except Exception:
            return Response(
                {'error': 'Error communicating with Sentry App service'},
                status=400)

        return Response(serialize(external_issue))
コード例 #8
0
    def post(self, request, installation):
        data = request.data.copy()

        if not set(["groupId", "action", "uri"]).issubset(data.keys()):
            return Response(status=400)

        group_id = data.get("groupId")
        del data["groupId"]

        try:
            group = Group.objects.get(
                id=group_id,
                project_id__in=Project.objects.filter(
                    organization_id=installation.organization_id),
            )
        except Group.DoesNotExist:
            return Response(status=404)

        action = data["action"]
        del data["action"]

        uri = data.get("uri")
        del data["uri"]

        try:
            external_issue = IssueLinkCreator.run(
                install=installation,
                group=group,
                action=action,
                fields=data,
                uri=uri,
                user=request.user,
            )
        except Exception:
            return Response(
                {"error": "Error communicating with Sentry App service"},
                status=400)

        return Response(serialize(external_issue))
コード例 #9
0
    def post(self, request, installation):
        data = request.DATA.copy()

        if not set(['groupId', 'action', 'uri']).issubset(data.keys()):
            return Response(status=400)

        group_id = data.get('groupId')
        del data['groupId']

        try:
            group = Group.objects.get(
                id=group_id,
                project_id__in=Project.objects.filter(
                    organization_id=installation.organization_id,
                )
            )
        except Group.DoesNotExist:
            return Response(status=404)

        action = data['action']
        del data['action']

        uri = data.get('uri')
        del data['uri']

        try:
            external_issue = IssueLinkCreator.run(
                install=installation,
                group=group,
                action=action,
                fields=data,
                uri=uri,
                user=request.user,
            )
        except Exception:
            return Response({'error': 'Error communicating with Sentry App service'}, status=400)

        return Response(serialize(external_issue))