How to use is_adding_testcase_to_issue_disabled method in Kiwi

Best Python code snippet using Kiwi_python

types.py

Source:types.py Github

copy

Full Screen

...64 # todo: we should allow this method to raise and the specific error65 # message must be returned to the caller instead of generic one.66 # as it is LinkOnly tracker doesn't have any integrations but the error67 # message is misleading68 def is_adding_testcase_to_issue_disabled(self):69 """70 When is linking a TC to a Bug report disabled?71 Usually when all the required credentials are provided.72 :return: - boolean73 """74 return not (self.tracker.api_url75 and self.tracker.api_username76 and self.tracker.api_password)77 def all_issues_link(self, _ids):78 """79 Used in testruns.views.get() aka run/report.html to produce80 a single URL which will open all reported issues into a single81 page in the Issue tracker. For example Bugzilla supports listing82 multiple bugs into a table. GitHub on the other hand doesn't83 support this functionality.84 :ids: - list of issues reported against test executions85 :return: - None if not suported or string representing the URL86 """87class Bugzilla(IssueTrackerType):88 """89 Support for Bugzilla. Requires:90 :api_url: - the XML-RPC URL for your Bugzilla instance91 :api_username: - a username registered in Bugzilla92 :api_password: - the password for this username93 You can also provide the ``BUGZILLA_AUTH_CACHE_DIR`` setting (in ``product.py``)94 to control where authentication cookies for Bugzilla will be saved. If this95 is not provided a temporary directory will be used each time we try to login96 into Bugzilla!97 """98 def __init__(self, tracker):99 super().__init__(tracker)100 # directory for Bugzilla credentials101 self._bugzilla_cache_dir = getattr(102 settings,103 "BUGZILLA_AUTH_CACHE_DIR",104 tempfile.mkdtemp(prefix='.bugzilla-')105 )106 if not os.path.exists(self._bugzilla_cache_dir):107 os.makedirs(self._bugzilla_cache_dir, 0o700)108 self._rpc = None109 @property110 def rpc(self):111 if self._rpc is None:112 self._rpc = bugzilla.Bugzilla(113 self.tracker.api_url,114 user=self.tracker.api_username,115 password=self.tracker.api_password,116 cookiefile=self._bugzilla_cache_dir + 'cookie',117 tokenfile=self._bugzilla_cache_dir + 'token',118 )119 return self._rpc120 def add_testcase_to_issue(self, testcases, issue):121 for case in testcases:122 bugzilla_integration.BugzillaThread(self.rpc, case, issue).start()123 def all_issues_link(self, ids):124 if not self.tracker.base_url:125 return None126 if not self.tracker.base_url.endswith('/'):127 self.tracker.base_url += '/'128 return self.tracker.base_url + 'buglist.cgi?bugidtype=include&bug_id=%s' % ','.join(ids)129 def report_issue_from_testcase(self, caserun):130 args = {}131 args['cf_build_id'] = caserun.run.build.name132 txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)133 comment = "Filed from caserun %s\n\n" % caserun.get_full_url()134 comment += "Version-Release number of selected " \135 "component (if applicable):\n"136 comment += '%s\n\n' % caserun.build.name137 comment += "Steps to Reproduce: \n%s\n\n" % txt138 comment += "Actual results: \n<describe what happened>\n\n"139 args['comment'] = comment140 args['component'] = caserun.case.component.values_list('name',141 flat=True)142 args['product'] = caserun.run.plan.product.name143 args['short_desc'] = 'Test case failure: %s' % caserun.case.summary144 args['version'] = caserun.run.product_version145 url = self.tracker.base_url146 if not url.endswith('/'):147 url += '/'148 return url + 'enter_bug.cgi?' + urlencode(args, True)149class JIRA(IssueTrackerType):150 """151 Support for JIRA. Requires:152 :api_url: - the API URL for your JIRA instance153 :api_username: - a username registered in JIRA154 :api_password: - the password for this username155 Additional control can be applied via the ``JIRA_OPTIONS`` configuration156 setting (in ``product.py``). By default this setting is not provided and157 the code uses ``jira.JIRA.DEFAULT_OPTIONS`` from the ``jira`` Python module!158 """159 def __init__(self, tracker):160 super(JIRA, self).__init__(tracker)161 if hasattr(settings, 'JIRA_OPTIONS'):162 options = settings.JIRA_OPTIONS163 else:164 options = None165 # b/c jira.JIRA tries to connect when object is created166 # see https://github.com/kiwitcms/Kiwi/issues/100167 if not self.is_adding_testcase_to_issue_disabled():168 self.rpc = jira.JIRA(169 tracker.api_url,170 basic_auth=(self.tracker.api_username, self.tracker.api_password),171 options=options,172 )173 def add_testcase_to_issue(self, testcases, issue):174 for case in testcases:175 jira_integration.JiraThread(self.rpc, case, issue).start()176 def all_issues_link(self, ids):177 if not self.tracker.base_url:178 return None179 if not self.tracker.base_url.endswith('/'):180 self.tracker.base_url += '/'181 return self.tracker.base_url + 'issues/?jql=issueKey%%20in%%20(%s)' % '%2C%20'.join(ids)182 def report_issue_from_testcase(self, caserun):183 """184 For the HTML API description see:185 https://confluence.atlassian.com/display/JIRA050/Creating+Issues+via+direct+HTML+links186 """187 # note: your jira instance needs to have the same projects188 # defined otherwise this will fail!189 project = self.rpc.project(caserun.run.plan.product.name)190 try:191 issue_type = self.rpc.issue_type_by_name('Bug')192 except KeyError:193 issue_type = self.rpc.issue_types()[0]194 args = {195 'pid': project.id,196 'issuetype': issue_type.id,197 'summary': 'Failed test: %s' % caserun.case.summary,198 }199 try:200 # apparently JIRA can't search users via their e-mail so try to201 # search by username and hope that it matches202 tested_by = caserun.tested_by203 if not tested_by:204 tested_by = caserun.assignee205 args['reporter'] = self.rpc.user(tested_by.username).key206 except jira.JIRAError:207 pass208 txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)209 comment = "Filed from caserun %s\n\n" % caserun.get_full_url()210 comment += "Product:\n%s\n\n" % caserun.run.plan.product.name211 comment += "Component(s):\n%s\n\n" % caserun.case.component.values_list('name', flat=True)212 comment += "Version-Release number of selected " \213 "component (if applicable):\n"214 comment += "%s\n\n" % caserun.build.name215 comment += "Steps to Reproduce: \n%s\n\n" % txt216 comment += "Actual results: \n<describe what happened>\n\n"217 args['description'] = comment218 url = self.tracker.base_url219 if not url.endswith('/'):220 url += '/'221 return url + '/secure/CreateIssueDetails!init.jspa?' + urlencode(args, True)222class GitHub(IssueTrackerType):223 """224 Support for GitHub. Requires:225 :base_url: - URL to a GitHub repository for which we're going to report issues226 :api_password: - GitHub API token.227 .. note::228 You can leave the ``api_url`` and ``api_username`` fields blank because229 the integration code doesn't use them!230 .. note::231 GitHub does not support displaying multiple issues in a table format like232 Bugzilla and JIRA do. This means that in Test Execution Report view you will233 see GitHub issues listed one by one and there will not be a link to open all234 of them inside GitHub's interface!235 """236 def __init__(self, tracker):237 super(GitHub, self).__init__(tracker)238 # NOTE: we use an access token so only the password field is required239 self.rpc = github.Github(self.tracker.api_password)240 def add_testcase_to_issue(self, testcases, issue):241 for case in testcases:242 github_integration.GitHubThread(self.rpc, self.tracker, case, issue).start()243 def is_adding_testcase_to_issue_disabled(self):244 return not (self.tracker.base_url and self.tracker.api_password)245 def report_issue_from_testcase(self, caserun):246 """247 GitHub only supports title and body parameters248 """249 args = {250 'title': 'Failed test: %s' % caserun.case.summary,251 }252 txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)253 comment = "Filed from caserun %s\n\n" % caserun.get_full_url()254 comment += "Product:\n%s\n\n" % caserun.run.plan.product.name255 comment += "Component(s):\n%s\n\n" % caserun.case.component.values_list('name', flat=True)256 comment += "Version-Release number of selected " \257 "component (if applicable):\n"258 comment += "%s\n\n" % caserun.build.name259 comment += "Steps to Reproduce: \n%s\n\n" % txt260 comment += "Actual results: \n<describe what happened>\n\n"261 args['body'] = comment262 url = self.tracker.base_url263 if not url.endswith('/'):264 url += '/'265 return url + '/issues/new?' + urlencode(args, True)266class Gitlab(IssueTrackerType):267 """268 Support for Gitlab. Requires:269 :base_url: - URL to a Gitlab repository for which we're going to report issues270 :api_password: - Gitlab API token.271 """272 def __init__(self, tracker):273 super(Gitlab, self).__init__(tracker)274 # we use an access token so only the password field is required275 self.rpc = gitlab.Gitlab(self.tracker.api_url, private_token=self.tracker.api_password)276 def add_testcase_to_issue(self, testcases, issue):277 for case in testcases:278 gitlab_integration.GitlabThread(self.rpc, self.tracker, case, issue).start()279 def is_adding_testcase_to_issue_disabled(self):280 return not (self.tracker.base_url and self.tracker.api_password)281 def report_issue_from_testcase(self, caserun):282 args = {283 'issue[title]': 'Failed test: %s' % caserun.case.summary,284 }285 txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)286 comment = "Filed from caserun %s\n\n" % caserun.get_full_url()287 comment += "**Product**:\n%s\n\n" % caserun.run.plan.product.name288 comment += "**Component(s)**:\n%s\n\n"\289 % caserun.case.component.values_list('name', flat=True)290 comment += "Version-Release number of selected " \291 "component (if applicable):\n"292 comment += "%s\n\n" % caserun.build.name293 comment += "**Steps to Reproduce**: \n%s\n\n" % txt294 comment += "**Actual results**: \n<describe what happened>\n\n"295 args['issue[description]'] = comment296 url = self.tracker.base_url297 if not url.endswith('/'):298 url += '/'299 return url + '/issues/new?' + urlencode(args, True)300class LinkOnly(IssueTrackerType):301 """302 Allow only linking issues to TestExecution records. Can be used when your303 issue tracker is not integrated with Kiwi TCMS.304 No additional API integration available!305 """306 def is_adding_testcase_to_issue_disabled(self):...

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