Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks/gitlab: Remove redundant Deployment Hook fixtures.
Niloth P73fd96cc9924
diff --git a/zerver/webhooks/gitlab/fixtures/deployment_hook__running.json b/zerver/webhooks/gitlab/fixtures/deployment_hook.jsonsimilarity index 100%rename from zerver/webhooks/gitlab/fixtures/deployment_hook__running.jsonrename to zerver/webhooks/gitlab/fixtures/deployment_hook.jsondiff --git a/zerver/webhooks/gitlab/fixtures/deployment_hook__canceled.json b/zerver/webhooks/gitlab/fixtures/deployment_hook__canceled.jsondeleted file mode 100644index cb2694a5b42..00000000000--- a/zerver/webhooks/gitlab/fixtures/deployment_hook__canceled.json+++ /dev/null@@ -1,42 +0,0 @@-{- "object_kind": "deployment",- "status": "canceled",- "status_changed_at": "2025-05-02 12:36:52 +0000",- "deployment_id": 988610373,- "deployable_id": 9905830127,- "deployable_url": "https://gitlab.com/vedant8600317/test/-/jobs/9905830127",- "environment": "production",- "environment_tier": "production",- "environment_slug": "production",- "environment_external_url": null,- "project": {- "id": 69310893,- "name": "test",- "description": null,- "web_url": "https://gitlab.com/vedant8600317/test",- "avatar_url": null,- "git_ssh_url": "[email protected]:vedant8600317/test.git",- "git_http_url": "https://gitlab.com/vedant8600317/test.git",- "namespace": "vedant",- "visibility_level": 0,- "path_with_namespace": "vedant8600317/test",- "default_branch": "master",- "ci_config_path": "",- "homepage": "https://gitlab.com/vedant8600317/test",- "url": "[email protected]:vedant8600317/test.git",- "ssh_url": "[email protected]:vedant8600317/test.git",- "http_url": "https://gitlab.com/vedant8600317/test.git"- },- "short_sha": "c3cf29e8",- "user": {- "id": 27470334,- "name": "Vedant Joshi",- "username": "theofficialvedantjoshi",- "avatar_url": "https://secure.gravatar.com/avatar/0d29c5c241fe093697c078fbb8abc26b93d4ebbd1609dbbd3835e6b5602fea38?s=80&d=identicon",- "email": "[REDACTED]"- },- "user_url": "https://gitlab.com/theofficialvedantjoshi",- "commit_url": "https://gitlab.com/vedant8600317/test/-/commit/c3cf29e88c1b0a8a60df37f4687dd5060955d2ae",- "commit_title": "Update .gitlab-ci.yml file",- "ref": "master"-}diff --git a/zerver/webhooks/gitlab/fixtures/deployment_hook__failed.json b/zerver/webhooks/gitlab/fixtures/deployment_hook__failed.jsondeleted file mode 100644index 9991c25c7dc..00000000000--- a/zerver/webhooks/gitlab/fixtures/deployment_hook__failed.json+++ /dev/null@@ -1,42 +0,0 @@-{- "object_kind": "deployment",- "status": "failed",- "status_changed_at": "2025-05-02 12:30:19 +0000",- "deployment_id": 988604916,- "deployable_id": 9905759933,- "deployable_url": "https://gitlab.com/vedant8600317/test/-/jobs/9905759933",- "environment": "production",- "environment_tier": "production",- "environment_slug": "production",- "environment_external_url": null,- "project": {- "id": 69310893,- "name": "test",- "description": null,- "web_url": "https://gitlab.com/vedant8600317/test",- "avatar_url": null,- "git_ssh_url": "[email protected]:vedant8600317/test.git",- "git_http_url": "https://gitlab.com/vedant8600317/test.git",- "namespace": "vedant",- "visibility_level": 0,- "path_with_namespace": "vedant8600317/test",- "default_branch": "master",- "ci_config_path": "",- "homepage": "https://gitlab.com/vedant8600317/test",- "url": "[email protected]:vedant8600317/test.git",- "ssh_url": "[email protected]:vedant8600317/test.git",- "http_url": "https://gitlab.com/vedant8600317/test.git"- },- "short_sha": "846d8de0",- "user": {- "id": 27470334,- "name": "Vedant Joshi",- "username": "theofficialvedantjoshi",- "avatar_url": "https://secure.gravatar.com/avatar/0d29c5c241fe093697c078fbb8abc26b93d4ebbd1609dbbd3835e6b5602fea38?s=80&d=identicon",- "email": "[REDACTED]"- },- "user_url": "https://gitlab.com/theofficialvedantjoshi",- "commit_url": "https://gitlab.com/vedant8600317/test/-/commit/846d8de0b7b3d694954249d2fd5d87fbe8c84e4c",- "commit_title": "Update .gitlab-ci.yml file",- "ref": "master"-}diff --git a/zerver/webhooks/gitlab/fixtures/deployment_hook__success.json b/zerver/webhooks/gitlab/fixtures/deployment_hook__success.jsondeleted file mode 100644index 42ce9d46052..00000000000--- a/zerver/webhooks/gitlab/fixtures/deployment_hook__success.json+++ /dev/null@@ -1,42 +0,0 @@-{- "object_kind": "deployment",- "status": "success",- "status_changed_at": "2025-05-02 11:55:16 +0000",- "deployment_id": 988572802,- "deployable_id": 9905389091,- "deployable_url": "https://gitlab.com/vedant8600317/test/-/jobs/9905389091",- "environment": "production",- "environment_tier": "production",- "environment_slug": "production",- "environment_external_url": null,- "project": {- "id": 69310893,- "name": "test",- "description": null,- "web_url": "https://gitlab.com/vedant8600317/test",- "avatar_url": null,- "git_ssh_url": "[email protected]:vedant8600317/test.git",- "git_http_url": "https://gitlab.com/vedant8600317/test.git",- "namespace": "vedant",- "visibility_level": 0,- "path_with_namespace": "vedant8600317/test",- "default_branch": "master",- "ci_config_path": "",- "homepage": "https://gitlab.com/vedant8600317/test",- "url": "[email protected]:vedant8600317/test.git",- "ssh_url": "[email protected]:vedant8600317/test.git",- "http_url": "https://gitlab.com/vedant8600317/test.git"- },- "short_sha": "58793660",- "user": {- "id": 27470334,- "name": "Vedant Joshi",- "username": "theofficialvedantjoshi",- "avatar_url": "https://secure.gravatar.com/avatar/0d29c5c241fe093697c078fbb8abc26b93d4ebbd1609dbbd3835e6b5602fea38?s=80&d=identicon",- "email": "[REDACTED]"- },- "user_url": "https://gitlab.com/theofficialvedantjoshi",- "commit_url": "https://gitlab.com/vedant8600317/test/-/commit/58793660b22d6ceacbdc23b28a0562bca339702c",- "commit_title": "Update .gitlab-ci.yml file",- "ref": "master"-}diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.pyindex 22780efd812..fee8c70922a 100644--- a/zerver/webhooks/gitlab/tests.py+++ b/zerver/webhooks/gitlab/tests.py@@ -723,51 +723,30 @@ A trivial change that should probably be ignored."resource_access_token_hook__group_expiry", expected_topic_name, expected_message)- def test_deployment_started_event_message(self) -> None:+ def test_deployment_event_message_by_status(self) -> None:+ deployment_url = "https://gitlab.com/vedant8600317/test/-/jobs/9905389091"expected_topic_name = "test / production"- expected_message = "[Vedant Joshi](https://gitlab.com/theofficialvedantjoshi) started a new [deployment](https://gitlab.com/vedant8600317/test/-/jobs/9905389091):\n> [5879366](https://gitlab.com/vedant8600317/test/-/commit/58793660b22d6ceacbdc23b28a0562bca339702c) Update .gitlab-ci.yml file"-- self.check_webhook(- "deployment_hook__running",- expected_topic_name,- expected_message,- HTTP_X_GITLAB_EVENT="Deployment Hook",- )-- def test_deployment_succeeded_event_message(self) -> None:- expected_topic_name = "test / production"- expected_message = "The [deployment](https://gitlab.com/vedant8600317/test/-/jobs/9905389091) was successful."-- self.check_webhook(- "deployment_hook__success",- expected_topic_name,- expected_message,- HTTP_X_GITLAB_EVENT="Deployment Hook",- )-- def test_deployment_failed_event_message(self) -> None:- expected_topic_name = "test / production"- expected_message = (- "The [deployment](https://gitlab.com/vedant8600317/test/-/jobs/9905759933) failed."- )-- self.check_webhook(- "deployment_hook__failed",- expected_topic_name,- expected_message,- HTTP_X_GITLAB_EVENT="Deployment Hook",- )+ test_cases = [+ (+ "running",+ f"[Vedant Joshi](https://gitlab.com/theofficialvedantjoshi) started a new [deployment]({deployment_url}):\n> [5879366](https://gitlab.com/vedant8600317/test/-/commit/58793660b22d6ceacbdc23b28a0562bca339702c) Update .gitlab-ci.yml file",+ ),+ ("success", f"The [deployment]({deployment_url}) was successful."),+ ("failed", f"The [deployment]({deployment_url}) failed."),+ ("canceled", f"The [deployment]({deployment_url}) was canceled."),+ ]- def test_deployment_canceled_event_message(self) -> None:- expected_topic_name = "test / production"- expected_message = "The [deployment](https://gitlab.com/vedant8600317/test/-/jobs/9905830127) was canceled."+ payload = orjson.loads(self.get_body("deployment_hook"))- self.check_webhook(- "deployment_hook__canceled",- expected_topic_name,- expected_message,- HTTP_X_GITLAB_EVENT="Deployment Hook",- )+ for status, expected_message in test_cases:+ with self.subTest(status=status):+ payload["status"] = status+ self.check_webhook(+ "deployment_hook",+ expected_topic_name,+ expected_message,+ custom_payload=payload,+ )def test_emoji_award_in_snippet(self) -> None:expected_topic_name = "sample / snippet #4831194 Sample Snippet"