Skip to content

Commit

Permalink
Don't link TC to Issue Trackers if required parameters not present
Browse files Browse the repository at this point in the history
By default these are api_url, api_username and api_password.
For GitHub they are base_url and api_password. Fixes #3
  • Loading branch information
atodorov committed Jun 28, 2017
1 parent 77e19a0 commit 4b32840
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tcms/issuetracker/types.py
Expand Up @@ -55,6 +55,12 @@ def add_testcase_to_issue(self, testcases, issue):
"""
raise NotImplementedError()

def is_adding_testcase_to_issue_disabled(self):
"""
When is linking a TC to a Bug disabled?
"""
return not (self.tracker.api_url and self.tracker.api_username and self.tracker.api_password)

def all_issues_link(self, ids):
"""
Used in testruns.views.get() aka run/report.html to produce
Expand Down Expand Up @@ -249,6 +255,12 @@ def add_testcase_to_issue(self, testcases, issue):
for case in testcases:
github_integration.GitHubThread(self.rpc, self.tracker, case, issue).start()

def is_adding_testcase_to_issue_disabled(self):
"""
Only disabled if we don't have an authentication token
"""
return not (self.tracker.base_url and self.tracker.api_password)

def report_issue_from_testcase(self, caserun):
"""
GitHub only supports title and body parameters
Expand Down
5 changes: 4 additions & 1 deletion tcms/testcases/models.py
Expand Up @@ -333,7 +333,10 @@ def add_bug(self, bug_id, bug_system_id, summary=None, description=None,
if bz_external_track:
bug_system = TestCaseBugSystem.objects.get(pk=bug_system_id)
it = IssueTrackerType.from_name(bug_system.tracker_type)(bug_system)
it.add_testcase_to_issue([self], bug)
if not it.is_adding_testcase_to_issue_disabled():
it.add_testcase_to_issue([self], bug)
else:
raise ValueError('Enable linking test cases by configuring API parameters for this Issue Tracker!')
else:
raise ValueError('Bug %s already exist.' % bug_id)

Expand Down

0 comments on commit 4b32840

Please sign in to comment.