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.

webhook tests: Avoid check_webhook for multi messages.

Steve Howellfae3535e791d
diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py
index 4663c47d7d0..25e7b29125c 100644
--- a/zerver/webhooks/bitbucket2/tests.py
+++ b/zerver/webhooks/bitbucket2/tests.py
@@ -272,7 +272,17 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push',
}
- self.check_webhook("push_more_than_one_tag", **kwargs)
+
+ self.subscribe(self.test_user, self.STREAM_NAME)
+ payload = self.get_body("push_more_than_one_tag")
+
+ msg = self.send_webhook_payload(
+ self.test_user,
+ self.url,
+ payload,
+ content_type="application/json",
+ **kwargs,
+ )
msg = self.get_second_to_last_message()
self.assert_stream_message(
@@ -294,7 +304,17 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push',
}
- self.check_webhook("more_than_one_push_event", **kwargs)
+
+ self.subscribe(self.test_user, self.STREAM_NAME)
+ payload = self.get_body("more_than_one_push_event")
+
+ msg = self.send_webhook_payload(
+ self.test_user,
+ self.url,
+ payload,
+ content_type="application/json",
+ **kwargs,
+ )
msg = self.get_second_to_last_message()
self.assert_stream_message(
@@ -317,7 +337,17 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push',
}
- self.check_webhook("more_than_one_push_event", **kwargs)
+
+ self.subscribe(self.test_user, self.STREAM_NAME)
+ payload = self.get_body("more_than_one_push_event")
+
+ msg = self.send_webhook_payload(
+ self.test_user,
+ self.url,
+ payload,
+ content_type="application/json",
+ **kwargs,
+ )
msg = self.get_second_to_last_message()
self.assert_stream_message(
diff --git a/zerver/webhooks/bitbucket3/tests.py b/zerver/webhooks/bitbucket3/tests.py
index dbbd1a4731e..4fb156ca713 100644
--- a/zerver/webhooks/bitbucket3/tests.py
+++ b/zerver/webhooks/bitbucket3/tests.py
@@ -68,7 +68,15 @@ class Bitbucket3HookTests(WebhookTestCase):
branch1_content = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""
master_content = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""
- self.check_webhook("repo_push_update_multiple_branches")
+ self.subscribe(self.test_user, self.STREAM_NAME)
+ payload = self.get_body("repo_push_update_multiple_branches")
+
+ msg = self.send_webhook_payload(
+ self.test_user,
+ self.url,
+ payload,
+ content_type="application/json",
+ )
msg = self.get_second_to_last_message()
self.assert_stream_message(
diff --git a/zerver/webhooks/updown/tests.py b/zerver/webhooks/updown/tests.py
index a68408ccab3..ccdf7a3aedc 100644
--- a/zerver/webhooks/updown/tests.py
+++ b/zerver/webhooks/updown/tests.py
@@ -27,7 +27,15 @@ class UpdownHookTests(WebhookTestCase):
down_content = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC."
up_content = "Service is `up` again after 1 second."
- self.check_webhook("check_multiple_events")
+ self.subscribe(self.test_user, self.STREAM_NAME)
+ payload = self.get_body("check_multiple_events")
+
+ msg = self.send_webhook_payload(
+ self.test_user,
+ self.url,
+ payload,
+ content_type="application/json",
+ )
msg = self.get_second_to_last_message()
self.assert_stream_message(