webhook tests: Avoid check_webhook for multi messages.

If we're not passing in expected_topic or expected_message
to check_webhook, it's better to just call send_webhook_payload,
since we'll want to explicitly check our messages
anyway.

This preps us to always require those fields for
check_webhook, which can prevent insidious testing no-ops.
This commit is contained in:
Steve Howell 2020-08-24 15:53:05 +00:00 committed by Tim Abbott
parent f74aa29a1c
commit fae3535e79
3 changed files with 51 additions and 5 deletions

View File

@ -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(

View File

@ -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(

View File

@ -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(