|
| 1 | +"""This module includes classes representing RP issues. |
| 2 | +
|
| 3 | +Issues are reported within the test item result PUT call. One issue can be |
| 4 | +associated with multiple external issues. By external issues is meant issues |
| 5 | +at the existing bug tracker systems. The following keys need to be sent in |
| 6 | +order to add an issue to the test result: |
| 7 | +
|
| 8 | +{ |
| 9 | + ..., |
| 10 | + "issue": { |
| 11 | + "autoAnalyzed": true, |
| 12 | + "comment": "string", |
| 13 | + "externalSystemIssues": [ |
| 14 | + { |
| 15 | + "btsProject": "string", |
| 16 | + "btsUrl": "string", |
| 17 | + "submitDate": 0, |
| 18 | + "ticketId": "string", |
| 19 | + "url": "string" |
| 20 | + } |
| 21 | + ], |
| 22 | + "ignoreAnalyzer": true, |
| 23 | + "issueType": "string" |
| 24 | + } |
| 25 | + ... |
| 26 | +} |
| 27 | +""" |
| 28 | + |
| 29 | + |
| 30 | +class Issue(object): |
| 31 | + """This class represents an issue that can be attached to test result.""" |
| 32 | + |
| 33 | + def __init__(self, |
| 34 | + issue_type, |
| 35 | + comment=None, |
| 36 | + auto_analyzed=False, |
| 37 | + ignore_analyzer=True): |
| 38 | + """Initialize instance attributes. |
| 39 | +
|
| 40 | + :param issue_type: Type of the issue. One of the followings: |
| 41 | + NOT_ISSUE, ab001, pb001, si001, nd001, ti001 |
| 42 | + :param comment: Issue comments |
| 43 | + :param auto_analyzed: Indicator that the issue has been marked with |
| 44 | + the RP auto analyzer |
| 45 | + :param ignore_analyzer: Flag that forces RP analyzer to ignore this |
| 46 | + issue |
| 47 | + """ |
| 48 | + self._external_issues = [] |
| 49 | + self.auto_analyzed = auto_analyzed |
| 50 | + self.comment = comment |
| 51 | + self.ignore_analyzer = ignore_analyzer |
| 52 | + self.issue_type = issue_type |
| 53 | + |
| 54 | + def external_issue_add(self, issue): |
| 55 | + """Add external system issue to the issue.""" |
| 56 | + self._external_issues.append(issue.payload) |
| 57 | + |
| 58 | + @property |
| 59 | + def payload(self): |
| 60 | + """Form the correct dictionary for the issue.""" |
| 61 | + return { |
| 62 | + 'autoAnalyzed': self.auto_analyzed, |
| 63 | + 'comment': self.comment, |
| 64 | + 'externalSystemIssues': self._external_issues, |
| 65 | + 'ignoreAnalyzer': self.ignore_analyzer, |
| 66 | + 'issueType': self.issue_type |
| 67 | + } |
| 68 | + |
| 69 | + |
| 70 | +class ExternalIssue(object): |
| 71 | + """This class represents external(BTS) system issue.""" |
| 72 | + |
| 73 | + def __init__(self, |
| 74 | + bts_url=None, |
| 75 | + bts_project=None, |
| 76 | + submit_date=None, |
| 77 | + ticket_id=None, |
| 78 | + url=None): |
| 79 | + """Initialize instance attributes. |
| 80 | +
|
| 81 | + :param bts_url: Bug tracker system URL |
| 82 | + :param bts_project: Bug tracker system project |
| 83 | + :param submit_date: Bug submission date |
| 84 | + :param ticket_id: Unique ID of the ticket at the BTS |
| 85 | + :param url: URL to the ticket(bug) |
| 86 | + """ |
| 87 | + self.bts_url = bts_url |
| 88 | + self.bts_project = bts_project |
| 89 | + self.submit_date = submit_date |
| 90 | + self.ticket_id = ticket_id |
| 91 | + self.url = url |
| 92 | + |
| 93 | + @property |
| 94 | + def payload(self): |
| 95 | + """Form the correct dictionary for the BTS issue.""" |
| 96 | + return { |
| 97 | + 'brsUrl': self.bts_url, |
| 98 | + 'btsProject': self.bts_project, |
| 99 | + 'submitDate': self.submit_date, |
| 100 | + 'ticketId': self.ticket_id, |
| 101 | + 'url': self.url |
| 102 | + } |
0 commit comments