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 Wiki Page Hook fixture.

Niloth P316931bcd26e
diff --git a/zerver/webhooks/gitlab/fixtures/wiki_page_hook__wiki_page_opened.json b/zerver/webhooks/gitlab/fixtures/wiki_page_hook.json
similarity index 100%
rename from zerver/webhooks/gitlab/fixtures/wiki_page_hook__wiki_page_opened.json
rename to zerver/webhooks/gitlab/fixtures/wiki_page_hook.json
diff --git a/zerver/webhooks/gitlab/fixtures/wiki_page_hook__wiki_page_edited.json b/zerver/webhooks/gitlab/fixtures/wiki_page_hook__wiki_page_edited.json
deleted file mode 100644
index a778f00c10f..00000000000
--- a/zerver/webhooks/gitlab/fixtures/wiki_page_hook__wiki_page_edited.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "object_kind":"wiki_page",
- "user":{
- "name":"Tomasz Kolek",
- "username":"tomaszkolek0",
- "avatar_url":"https://secure.gravatar.com/avatar/116a6fdbcfd00466297a39174da11fbb?s=80\u0026d=identicon"
- },
- "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"
- },
- "wiki":{
- "web_url":"https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/home",
- "git_ssh_url":"[email protected]:tomaszkolek0/my-awesome-project.wiki.git",
- "git_http_url":"https://gitlab.com/tomaszkolek0/my-awesome-project.wiki.git",
- "path_with_namespace":"tomaszkolek0/my-awesome-project.wiki",
- "default_branch":"master"
- },
- "object_attributes":{
- "slug":"how-to",
- "title":"how to",
- "format":"markdown",
- "content":"abcaaa",
- "url":"https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to",
- "action":"update"
- }
-}
diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py
index c419bf9b232..4d66104e084 100644
--- a/zerver/webhooks/gitlab/tests.py
+++ b/zerver/webhooks/gitlab/tests.py
@@ -437,21 +437,27 @@ A trivial change that should probably be ignored.
expect_noop=True,
)
- def test_wiki_page_opened_event_message(self) -> None:
- expected_topic_name = "my-awesome-project"
- expected_message = 'Tomasz Kolek created [wiki page "how to"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to).'
-
- self.check_webhook(
- "wiki_page_hook__wiki_page_opened", expected_topic_name, expected_message
+ def test_wiki_page_event_messages(self) -> None:
+ wiki_page_link = (
+ '[wiki page "how to"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)'
)
-
- def test_wiki_page_edited_event_message(self) -> None:
expected_topic_name = "my-awesome-project"
- expected_message = 'Tomasz Kolek updated [wiki page "how to"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to).'
+ test_cases = [
+ ("create", f"Tomasz Kolek created {wiki_page_link}."),
+ ("update", f"Tomasz Kolek updated {wiki_page_link}."),
+ ]
- self.check_webhook(
- "wiki_page_hook__wiki_page_edited", expected_topic_name, expected_message
- )
+ payload = orjson.loads(self.get_body("wiki_page_hook"))
+
+ for action, expected_message in test_cases:
+ with self.subTest(action=action):
+ payload["object_attributes"]["action"] = action
+ self.check_webhook(
+ "wiki_page_hook",
+ expected_topic_name,
+ expected_message,
+ custom_payload=payload,
+ )
def test_pipeline_succeeded_with_artifacts_event_message(self) -> None:
expected_topic_name = "onlysomeproject / test/links-in-zulip-pipeline-message"