mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
webhooks/gitlab: Get test coverage up to 100%.
Test coverage was improved by removing an unused function and removing some code (written by me) that was actually handling Test Hook event types incorrectly.
This commit is contained in:
@@ -101,7 +101,6 @@ not_yet_fully_covered = {
|
|||||||
'zerver/data_import/import_util.py',
|
'zerver/data_import/import_util.py',
|
||||||
# Webhook integrations with incomplete coverage
|
# Webhook integrations with incomplete coverage
|
||||||
'zerver/webhooks/github_legacy/view.py',
|
'zerver/webhooks/github_legacy/view.py',
|
||||||
'zerver/webhooks/gitlab/view.py',
|
|
||||||
'zerver/webhooks/greenhouse/view.py',
|
'zerver/webhooks/greenhouse/view.py',
|
||||||
'zerver/webhooks/hellosign/view.py',
|
'zerver/webhooks/hellosign/view.py',
|
||||||
'zerver/webhooks/ifttt/view.py',
|
'zerver/webhooks/ifttt/view.py',
|
||||||
|
|||||||
@@ -261,9 +261,6 @@ def get_branch_name(payload: Dict[str, Any]) -> str:
|
|||||||
def get_tag_name(payload: Dict[str, Any]) -> str:
|
def get_tag_name(payload: Dict[str, Any]) -> str:
|
||||||
return payload['ref'].replace('refs/tags/', '')
|
return payload['ref'].replace('refs/tags/', '')
|
||||||
|
|
||||||
def get_object_iid(payload: Dict[str, Any]) -> str:
|
|
||||||
return payload['object_attributes']['iid']
|
|
||||||
|
|
||||||
def get_object_url(payload: Dict[str, Any]) -> str:
|
def get_object_url(payload: Dict[str, Any]) -> str:
|
||||||
return payload['object_attributes']['url']
|
return payload['object_attributes']['url']
|
||||||
|
|
||||||
@@ -364,13 +361,9 @@ def get_subject_based_on_event(event: str, payload: Dict[str, Any]) -> str:
|
|||||||
return get_repo_name(payload)
|
return get_repo_name(payload)
|
||||||
|
|
||||||
def get_event(request: HttpRequest, payload: Dict[str, Any], branches: Optional[str]) -> Optional[str]:
|
def get_event(request: HttpRequest, payload: Dict[str, Any], branches: Optional[str]) -> Optional[str]:
|
||||||
# if there is no 'action' attribute, then this is a test payload
|
|
||||||
# and we should ignore it
|
|
||||||
event = validate_extract_webhook_http_header(request, 'X_GITLAB_EVENT', 'GitLab')
|
event = validate_extract_webhook_http_header(request, 'X_GITLAB_EVENT', 'GitLab')
|
||||||
if event in ['Issue Hook', 'Merge Request Hook', 'Wiki Page Hook']:
|
if event in ['Issue Hook', 'Merge Request Hook', 'Wiki Page Hook']:
|
||||||
action = payload['object_attributes'].get('action')
|
action = payload['object_attributes'].get('action')
|
||||||
if action is None:
|
|
||||||
return 'Test Hook'
|
|
||||||
event = "{} {}".format(event, action)
|
event = "{} {}".format(event, action)
|
||||||
elif event == 'Note Hook':
|
elif event == 'Note Hook':
|
||||||
action = payload['object_attributes'].get('noteable_type')
|
action = payload['object_attributes'].get('noteable_type')
|
||||||
|
|||||||
Reference in New Issue
Block a user