How to use _report_comment method in Kiwi

Best Python code snippet using Kiwi_python

types.py

Source:types.py Github

copy

Full Screen

...79 new_issue = self.rpc.create_issue(80 project=project.id,81 issuetype={'name': issue_type.name},82 summary='Failed test: %s' % execution.case.summary,83 description=self._report_comment(execution),84 )85 new_url = self.bug_system.base_url + "/browse/" + new_issue.key86 # add a link reference that will be shown in the UI87 LinkReference.objects.get_or_create(88 execution=execution,89 url=new_url,90 is_defect=True,91 )92 return new_url93 except jira.exceptions.JIRAError:94 pass95 args = {96 'pid': project.id,97 'issuetype': issue_type.id,98 'summary': 'Failed test: %s' % execution.case.summary,99 'description': self._report_comment(execution),100 }101 url = self.bug_system.base_url102 if not url.endswith('/'):103 url += '/'104 return url + '/secure/CreateIssueDetails!init.jspa?' + urlencode(args, True)105class GitHub(IssueTrackerType):106 """107 Support for GitHub. Requires:108 :base_url: - URL to a GitHub repository for which we're going to report issues109 :api_password: - GitHub API token - needs ``repo`` or ``public_repo``110 permissions.111 .. note::112 You can leave the ``api_url`` and ``api_username`` fields blank because113 the integration code doesn't use them!114 """115 it_class = github_integration.GitHubThread116 def _rpc_connection(self):117 # NOTE: we use an access token so only the password field is required118 return github.Github(self.bug_system.api_password)119 def is_adding_testcase_to_issue_disabled(self):120 return not (self.bug_system.base_url and self.bug_system.api_password)121 def report_issue_from_testexecution(self, execution, user):122 """123 GitHub only supports title and body parameters124 """125 args = {126 'title': 'Failed test: %s' % execution.case.summary,127 'body': self._report_comment(execution),128 }129 try:130 repo_id = self.it_class.repo_id(self.bug_system)131 repo = self.rpc.get_repo(repo_id)132 issue = repo.create_issue(**args)133 # add a link reference that will be shown in the UI134 LinkReference.objects.get_or_create(135 execution=execution,136 url=issue.html_url,137 is_defect=True,138 )139 return issue.html_url140 except Exception: # pylint: disable=broad-except141 # something above didn't work so return a link for manually142 # entering issue details with info pre-filled143 url = self.bug_system.base_url144 if not url.endswith('/'):145 url += '/'146 return url + '/issues/new?' + urlencode(args, True)147 def details(self, url):148 """149 Use GitHub's API instead of OpenGraph to return bug150 details b/c it will work for both public and private URLs.151 """152 repo_id = self.it_class.repo_id(self.bug_system)153 repo = self.rpc.get_repo(repo_id)154 issue = repo.get_issue(self.bug_id_from_url(url))155 return {156 'title': issue.title,157 'description': issue.body,158 }159class Gitlab(IssueTrackerType):160 """161 Support for Gitlab. Requires:162 :base_url: URL to a GitLab repository for which we're going to report issues163 :api_url: URL to GitLab instance. Usually gitlab.com!164 :api_password: GitLab API token.165 .. note::166 You can leave ``api_username`` field blank because167 the integration code doesn't use it!168 """169 it_class = gitlab_integration.GitlabThread170 def _rpc_connection(self):171 # we use an access token so only the password field is required172 return gitlab.Gitlab(self.bug_system.api_url,173 private_token=self.bug_system.api_password)174 def is_adding_testcase_to_issue_disabled(self):175 return not (self.bug_system.api_url and self.bug_system.api_password)176 def report_issue_from_testexecution(self, execution, user):177 repo_id = self.it_class.repo_id(self.bug_system)178 project = self.rpc.projects.get(repo_id)179 new_issue = project.issues.create({180 'title': 'Failed test: %s' % execution.case.summary,181 'description': self._report_comment(execution),182 })183 # and also add a link reference that will be shown in the UI184 LinkReference.objects.get_or_create(185 execution=execution,186 url=new_issue.attributes['web_url'],187 is_defect=True,188 )189 return new_issue.attributes['web_url']190 def details(self, url):191 """192 Use Gitlab API instead of OpenGraph to return bug193 details b/c it will work for both public and private URLs.194 """195 repo_id = self.it_class.repo_id(self.bug_system)196 project = self.rpc.projects.get(repo_id)197 issue = project.issues.get(self.bug_id_from_url(url))198 return {199 'title': issue.title,200 'description': issue.description,201 }202class Redmine(IssueTrackerType):203 """204 Support for Redmine. Requires:205 :base_url: - the URL for this Redmine instance206 :api_username: - a username registered in Redmine207 :api_password: - the password for this username208 """209 it_class = redmine_integration.RedmineThread210 def is_adding_testcase_to_issue_disabled(self):211 return not (self.bug_system.base_url212 and self.bug_system.api_username213 and self.bug_system.api_password)214 def _rpc_connection(self):215 return redminelib.Redmine(216 self.bug_system.base_url,217 username=self.bug_system.api_username,218 password=self.bug_system.api_password219 )220 def details(self, url):221 try:222 issue = self.rpc.issue.get(self.bug_id_from_url(url))223 return {224 'title': issue.subject,225 'description': issue.description,226 }227 except redminelib.exceptions.ResourceNotFoundError:228 return super().details(url)229 def redmine_project_by_name(self, name):230 """231 Return a Redmine project which matches the given product name.232 If there is no match then return the first project in Redmine!233 """234 all_projects = self.rpc.project.all()235 for project in all_projects:236 if project.name == name:237 return project238 return all_projects[0]239 @staticmethod240 def redmine_tracker_by_name(project, name):241 """242 Return a Redmine tracker matching name ('Bugs').243 If there is no match then return the first one!244 """245 all_trackers = project.trackers246 for tracker in all_trackers:247 if tracker.name.lower() == name.lower():248 return tracker249 return all_trackers[0]250 def redmine_priority_by_name(self, name):251 all_priorities = self.rpc.enumeration.filter(resource='issue_priorities')252 for priority in all_priorities:253 if priority.name.lower() == name.lower():254 return priority255 return all_priorities[0]256 def report_issue_from_testexecution(self, execution, user):257 project = self.redmine_project_by_name(execution.run.plan.product.name)258 tracker = self.redmine_tracker_by_name(project, 'Bugs')259 # the first Issue Status in Redmine260 status = self.rpc.issue_status.all()[0]261 # try matching TC.priority with IssuePriority in Redmine262 priority = self.redmine_priority_by_name(execution.case.priority.value)263 new_issue = self.rpc.issue.create(264 subject='Failed test: %s' % execution.case.summary,265 description=self._report_comment(execution),266 project_id=project.id,267 tracker_id=tracker.id,268 status_id=status.id,269 priority_id=priority.id,270 )271 new_url = self.bug_system.base_url + "/issues/%d" % new_issue.id272 # and also add a link reference that will be shown in the UI273 LinkReference.objects.get_or_create(274 execution=execution,275 url=new_url,276 is_defect=True,277 )...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful