@@ 277-334 (lines=58) @@ | ||
274 | return url + '/secure/CreateIssueDetails!init.jspa?' + urlencode(args, True) |
|
275 | ||
276 | ||
277 | class GitHub(IssueTrackerType): |
|
278 | """ |
|
279 | Support for GitHub. Requires: |
|
280 | ||
281 | :base_url: - URL to a GitHub repository for which we're going to report issues |
|
282 | :api_password: - GitHub API token. |
|
283 | ||
284 | .. note:: |
|
285 | ||
286 | You can leave the ``api_url`` and ``api_username`` fields blank because |
|
287 | the integration code doesn't use them! |
|
288 | ||
289 | .. note:: |
|
290 | ||
291 | GitHub does not support displaying multiple issues in a table format like |
|
292 | Bugzilla and JIRA do. This means that in Test Case Run Report view you will |
|
293 | see GitHub issues listed one by one and there will not be a link to open all |
|
294 | of them inside GitHub's interface! |
|
295 | """ |
|
296 | ||
297 | def __init__(self, tracker): |
|
298 | super(GitHub, self).__init__(tracker) |
|
299 | ||
300 | # NOTE: we use an access token so only the password field is required |
|
301 | self.rpc = github.Github(self.tracker.api_password) |
|
302 | ||
303 | def add_testcase_to_issue(self, testcases, issue): |
|
304 | for case in testcases: |
|
305 | github_integration.GitHubThread(self.rpc, self.tracker, case, issue).start() |
|
306 | ||
307 | def is_adding_testcase_to_issue_disabled(self): |
|
308 | return not (self.tracker.base_url and self.tracker.api_password) |
|
309 | ||
310 | def report_issue_from_testcase(self, caserun): |
|
311 | """ |
|
312 | GitHub only supports title and body parameters |
|
313 | """ |
|
314 | args = { |
|
315 | 'title': 'Failed test: %s' % caserun.case.summary, |
|
316 | } |
|
317 | ||
318 | txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version) |
|
319 | ||
320 | comment = "Filed from caserun %s\n\n" % caserun.get_full_url() |
|
321 | comment += "Product:\n%s\n\n" % caserun.run.plan.product.name |
|
322 | comment += "Component(s):\n%s\n\n" % caserun.case.component.values_list('name', flat=True) |
|
323 | comment += "Version-Release number of selected " \ |
|
324 | "component (if applicable):\n" |
|
325 | comment += "%s\n\n" % caserun.build.name |
|
326 | comment += "Steps to Reproduce: \n%s\n\n" % txt |
|
327 | comment += "Actual results: \n<describe what happened>\n\n" |
|
328 | args['body'] = comment |
|
329 | ||
330 | url = self.tracker.base_url |
|
331 | if not url.endswith('/'): |
|
332 | url += '/' |
|
333 | ||
334 | return url + '/issues/new?' + urlencode(args, True) |
|
335 | ||
336 | ||
337 | class Gitlab(IssueTrackerType): |
|
@@ 337-380 (lines=44) @@ | ||
334 | return url + '/issues/new?' + urlencode(args, True) |
|
335 | ||
336 | ||
337 | class Gitlab(IssueTrackerType): |
|
338 | """ |
|
339 | Support for Gitlab. Requires: |
|
340 | ||
341 | :base_url: - URL to a Gitlab repository for which we're going to report issues |
|
342 | :api_password: - Gitlab API token. |
|
343 | """ |
|
344 | ||
345 | def __init__(self, tracker): |
|
346 | super(Gitlab, self).__init__(tracker) |
|
347 | ||
348 | # we use an access token so only the password field is required |
|
349 | self.rpc = gitlab.Gitlab(self.tracker.api_url, private_token=self.tracker.api_password) |
|
350 | ||
351 | def add_testcase_to_issue(self, testcases, issue): |
|
352 | for case in testcases: |
|
353 | gitlab_integration.GitlabThread(self.rpc, self.tracker, case, issue).start() |
|
354 | ||
355 | def is_adding_testcase_to_issue_disabled(self): |
|
356 | return not (self.tracker.base_url and self.tracker.api_password) |
|
357 | ||
358 | def report_issue_from_testcase(self, caserun): |
|
359 | args = { |
|
360 | 'issue[title]': 'Failed test: %s' % caserun.case.summary, |
|
361 | } |
|
362 | ||
363 | txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version) |
|
364 | ||
365 | comment = "Filed from caserun %s\n\n" % caserun.get_full_url() |
|
366 | comment += "**Product**:\n%s\n\n" % caserun.run.plan.product.name |
|
367 | comment += "**Component(s)**:\n%s\n\n"\ |
|
368 | % caserun.case.component.values_list('name', flat=True) |
|
369 | comment += "Version-Release number of selected " \ |
|
370 | "component (if applicable):\n" |
|
371 | comment += "%s\n\n" % caserun.build.name |
|
372 | comment += "**Steps to Reproduce**: \n%s\n\n" % txt |
|
373 | comment += "**Actual results**: \n<describe what happened>\n\n" |
|
374 | args['issue[description]'] = comment |
|
375 | ||
376 | url = self.tracker.base_url |
|
377 | if not url.endswith('/'): |
|
378 | url += '/' |
|
379 | ||
380 | return url + '/issues/new?' + urlencode(args, True) |
|
381 | ||
382 | ||
383 | class LinkOnly(IssueTrackerType): |