only consider issue numbers from PR title (#73089)
gitea-wip/gitea-redmine/pipeline/pr-main This commit looks good
Details
gitea-wip/gitea-redmine/pipeline/pr-main This commit looks good
Details
This commit is contained in:
parent
3e6855b459
commit
66b3f5ed25
|
@ -55,7 +55,7 @@ def incoming_webhook(token):
|
|||
logging.info('Skipping, no handler found for this webhook')
|
||||
return {'status': 'success', 'detail': 'Skipped, unhandled webhook'}
|
||||
|
||||
haystack = f'{payload["pull_request"]["body"]} {payload["pull_request"]["title"]}'
|
||||
haystack = payload['pull_request']['title']
|
||||
try:
|
||||
pr_branch = payload['pull_request']['head']['ref']
|
||||
except KeyError:
|
||||
|
|
11
test_app.py
11
test_app.py
|
@ -54,7 +54,7 @@ def test_get_handler(payload, expected_handler, expected_event):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'body, branch_name, expected',
|
||||
'text, branch_name, expected',
|
||||
[
|
||||
('None', '', []),
|
||||
('#1, #2', '', [1, 2]),
|
||||
|
@ -66,8 +66,8 @@ def test_get_handler(payload, expected_handler, expected_event):
|
|||
('#2 #3', 'wip/noop-2', [2, 3]),
|
||||
],
|
||||
)
|
||||
def test_get_issues_ids(body, branch_name, expected):
|
||||
assert gitea_redmine.get_issues_ids(body, branch_name) == expected
|
||||
def test_get_issues_ids(text, branch_name, expected):
|
||||
assert gitea_redmine.get_issues_ids(text, branch_name) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -418,7 +418,7 @@ def test_incoming_webhook_calls_proper_handler(client, mocker):
|
|||
"action": "foo",
|
||||
"pull_request": {
|
||||
"title": "Fix #1234",
|
||||
"body": "And #5678",
|
||||
"body": "And this was caused by #5678 that should not be referenced",
|
||||
"head": {
|
||||
"ref": "wip/9100-something"
|
||||
}
|
||||
|
@ -433,10 +433,9 @@ def test_incoming_webhook_calls_proper_handler(client, mocker):
|
|||
get_handler.assert_called_once_with(payload)
|
||||
handler = get_handler.return_value[0]
|
||||
|
||||
assert handler.call_count == 3
|
||||
assert handler.call_count == 2
|
||||
|
||||
get_redmine_issue.assert_any_call(1234)
|
||||
get_redmine_issue.assert_any_call(5678)
|
||||
get_redmine_issue.assert_any_call(9100)
|
||||
|
||||
handler.assert_any_call(issue1, payload, project)
|
||||
|
|
Loading…
Reference in New Issue