_handle_webhook_issue: Use yield instead of return

parent 14dce87c
Pipeline #35563463 passed with stage
in 30 seconds
......@@ -208,10 +208,9 @@ class GitHub(GitHubMixin, Hoster):
if trigger_event == IssueActions.ASSIGNEES_CHANGED:
assignees = data.get('assignees') or set()
users = {user['login'] for user in assignees}
return IssueActions.ASSIGNEES_CHANGED, [issue_obj, users]
if (trigger_event is IssueActions.LABELED
or trigger_event is IssueActions.UNLABELED):
yield IssueActions.ASSIGNEES_CHANGED, [issue_obj, users]
elif (trigger_event is IssueActions.LABELED
or trigger_event is IssueActions.UNLABELED):
yield trigger_event, [issue_obj, data['label']['name']]
else:
yield trigger_event, [issue_obj]
......
......@@ -213,10 +213,9 @@ class GitLab(GitLabMixin, Hoster):
'assignees' in data['changes']):
assignees = data['changes']['assignees']['current']
users = {user['username'] for user in assignees}
return IssueActions.ASSIGNEES_CHANGED, [issue_obj, users]
if (trigger_event == IssueActions.ATTRIBUTES_CHANGED and
'labels' in data['changes']):
yield IssueActions.ASSIGNEES_CHANGED, [issue_obj, users]
elif (trigger_event == IssueActions.ATTRIBUTES_CHANGED and
'labels' in data['changes']):
# labels are changed
yield from type(self)._handle_labels(
IssueActions, issue_obj, data)
......
......@@ -228,9 +228,10 @@ class TestGitHubWebhook(IGittTestCase):
self.assertIsInstance(obj[0], GitHubIssue)
self.assertEqual(obj[1], {'gitmate-bot'})
self.default_data.update({
'action': 'unassigned'
'action': 'unassigned',
'assignees': set()
})
for event, obj in self.gh.handle_webhook('issues', self.default_data):
self.assertEqual(event, IssueActions.UNLABELED)
self.assertEqual(event, IssueActions.ASSIGNEES_CHANGED)
self.assertIsInstance(obj[0], GitHubIssue)
self.assertEqual(obj[1], set())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment