Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks/gitlab: Remove redundant Tag Push Hook fixture.

Niloth Pe3ddc5bd4613
diff --git a/zerver/webhooks/gitlab/fixtures/tag_push_hook__add_tag.json b/zerver/webhooks/gitlab/fixtures/tag_push_hook.json
similarity index 100%
rename from zerver/webhooks/gitlab/fixtures/tag_push_hook__add_tag.json
rename to zerver/webhooks/gitlab/fixtures/tag_push_hook.json
diff --git a/zerver/webhooks/gitlab/fixtures/tag_push_hook__remove_tag.json b/zerver/webhooks/gitlab/fixtures/tag_push_hook__remove_tag.json
deleted file mode 100644
index 24b5dc9b79e..00000000000
--- a/zerver/webhooks/gitlab/fixtures/tag_push_hook__remove_tag.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "object_kind":"tag_push",
- "event_name":"tag_push",
- "before":"0000000000000000000000000000000000000000",
- "after":"eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9",
- "ref":"refs/tags/xyz",
- "checkout_sha": null,
- "message":null,
- "user_id":670043,
- "user_name":"Tomasz Kolek",
- "user_username":"tomaszkolek0",
- "user_email":"[email protected]",
- "user_avatar":"https://secure.gravatar.com/avatar/116a6fdbcfd00466297a39174da11fbb?s=80\u0026d=identicon",
- "project_id":1534233,
- "project":{
- "name":"my-awesome-project",
- "description":"",
- "web_url":"https://gitlab.com/tomaszkolek0/my-awesome-project",
- "avatar_url":null,
- "git_ssh_url":"[email protected]:tomaszkolek0/my-awesome-project.git",
- "git_http_url":"https://gitlab.com/tomaszkolek0/my-awesome-project.git",
- "namespace":"tomaszkolek0",
- "visibility_level":0,
- "path_with_namespace":"tomaszkolek0/my-awesome-project",
- "default_branch":"master",
- "homepage":"https://gitlab.com/tomaszkolek0/my-awesome-project",
- "url":"[email protected]:tomaszkolek0/my-awesome-project.git",
- "ssh_url":"[email protected]:tomaszkolek0/my-awesome-project.git",
- "http_url":"https://gitlab.com/tomaszkolek0/my-awesome-project.git"
- },
- "commits":[
-
- ],
- "total_commits_count":0,
- "repository":{
- "name":"my-awesome-project",
- "url":"[email protected]:tomaszkolek0/my-awesome-project.git",
- "description":"",
- "homepage":"https://gitlab.com/tomaszkolek0/my-awesome-project",
- "git_http_url":"https://gitlab.com/tomaszkolek0/my-awesome-project.git",
- "git_ssh_url":"[email protected]:tomaszkolek0/my-awesome-project.git",
- "visibility_level":0
- }
-}
diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py
index 4d66104e084..e0c5c2b5d07 100644
--- a/zerver/webhooks/gitlab/tests.py
+++ b/zerver/webhooks/gitlab/tests.py
@@ -75,22 +75,20 @@ class GitlabHookTests(WebhookTestCase):
self.check_webhook("push_hook__remove_branch", expected_topic_name, expected_message)
- def test_add_tag_event_message(self) -> None:
+ def test_tag_push_event_messages(self) -> None:
expected_topic_name = "my-awesome-project"
- expected_message = "Tomasz Kolek pushed tag xyz."
-
- self.check_webhook(
- "tag_push_hook__add_tag",
- expected_topic_name,
- expected_message,
- HTTP_X_GITLAB_EVENT="Tag Push Hook",
- )
-
- def test_remove_tag_event_message(self) -> None:
- expected_topic_name = "my-awesome-project"
- expected_message = "Tomasz Kolek removed tag xyz."
+ payload = orjson.loads(self.get_body("tag_push_hook"))
+ test_cases = [
+ (payload["checkout_sha"], "Tomasz Kolek pushed tag xyz."),
+ (None, "Tomasz Kolek removed tag xyz."),
+ ]
- self.check_webhook("tag_push_hook__remove_tag", expected_topic_name, expected_message)
+ for checkout_sha, expected_message in test_cases:
+ with self.subTest(checkout_sha=checkout_sha):
+ payload["checkout_sha"] = checkout_sha
+ self.check_webhook(
+ "tag_push_hook", expected_topic_name, expected_message, custom_payload=payload
+ )
def test_create_issue_without_assignee_event_message(self) -> None:
expected_topic_name = "my-awesome-project / issue #1 Issue title"