webhook tests: Rename main helper to check_webhook.

Almost all webhook tests use this helper, except a few
webhooks that write to private streams.

Being concise is important here, and the name
`self.send_and_test_stream_message` always confused
me, since it sounds you're sending a stream message,
and it leaves out the webhook piece.

We should consider renaming `send_and_test_private_message`
to something like `check_webhook_private`, but I couldn't
decide on a great name, and it's very rarely used.  So
for now I just made sure the docstrings of the two
sibling functions reference each other.
This commit is contained in:
Steve Howell
2020-08-23 13:49:24 +00:00
committed by Tim Abbott
parent 00001a396b
commit 388053db6b
71 changed files with 1726 additions and 1467 deletions

View File

@@ -18,10 +18,9 @@ Hire Candidate Johnny Smith (ID: 19), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip()
self.send_and_test_stream_message('candidate_hired',
expected_topic,
expected_message,
content_type=self.CONTENT_TYPE)
self.check_webhook(
"candidate_hired", expected_topic, expected_message, content_type=self.CONTENT_TYPE
)
def test_message_candidate_rejected(self) -> None:
expected_topic = "Reject Candidate - 265788"
@@ -32,10 +31,9 @@ Reject Candidate Hector Porter (ID: 265788), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip()
self.send_and_test_stream_message('candidate_rejected',
expected_topic,
expected_message,
content_type=self.CONTENT_TYPE)
self.check_webhook(
"candidate_rejected", expected_topic, expected_message, content_type=self.CONTENT_TYPE
)
def test_message_candidate_stage_change(self) -> None:
expected_topic = "Candidate Stage Change - 265772"
@@ -46,10 +44,12 @@ Candidate Stage Change Giuseppe Hurley (ID: 265772), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...), [Cover_Letter](https://prod-heroku.s3.amazonaws.com/...), [Attachment](https://prod-heroku.s3.amazonaws.com/...)
""".strip()
self.send_and_test_stream_message('candidate_stage_change',
expected_topic,
expected_message,
content_type=self.CONTENT_TYPE)
self.check_webhook(
"candidate_stage_change",
expected_topic,
expected_message,
content_type=self.CONTENT_TYPE,
)
def test_message_prospect_created(self) -> None:
expected_topic = "New Prospect Application - 968190"
@@ -60,10 +60,9 @@ New Prospect Application Trisha Troy (ID: 968190), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip()
self.send_and_test_stream_message('prospect_created',
expected_topic,
expected_message,
content_type=self.CONTENT_TYPE)
self.check_webhook(
"prospect_created", expected_topic, expected_message, content_type=self.CONTENT_TYPE
)
@patch('zerver.webhooks.greenhouse.view.check_send_webhook_message')
def test_ping_message_ignore(