def test_link_issue_with_comment(self):
responses.add(
responses.PATCH,
'https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workitems/309?api-version=3.0',
body=WORK_ITEM_RESPONSE,
content_type='application/json',
)
self.plugin.set_option(
'instance', 'fabrikam-fiber-inc.visualstudio.com', self.project)
group = self.create_group(message='Hello world', culprit='foo.bar')
request = self.request.get('/')
request.user = AnonymousUser()
form_data = {
'item_id': '309',
'comment': 'Fix this.',
}
with self.assertRaises(PluginError):
self.plugin.link_issue(request, group, form_data)
request.user = self.user
self.login_as(self.user)
UserSocialAuth.objects.create(
user=self.user,
provider=self.plugin.auth_provider,
uid='a89e7204-9ca0-4680-ba7a-cfcf6b3c7445',
extra_data={
'access_token': 'foo',
'refresh_token': 'bar',
}
)
assert self.plugin.link_issue(request, group, form_data) == {
'id': 309,
'title': 'Customer can sign in using their Microsoft Account',
'url': 'https://fabrikam-fiber-inc.visualstudio.com/web/wi.aspx?pcguid=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&id=309',
}
request = responses.calls[-1].request
assert request.headers['Content-Type'] == 'application/json-patch+json'
payload = json.loads(request.body)
assert payload == [
{
'op': 'add',
'path': '/fields/System.History',
'value': '<p>Fix this.</p>\n',
},
# {
# "op": "add",
# "path": "/relations/-",
# "value": {
# "rel": "Hyperlink",
# "url": 'http://testserver/baz/bar/issues/1/',
# }
# }
]
评论列表
文章目录