mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Since FIXTURE_DIR_NAME is the name of the folder that contains the view and tests modules of the webhook and another folder called "fixtures" that store the fixtures, it is more appropriate to call it WEBHOOK_DIR_NAME, especially when we want to refer to the view module using this variable.
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
from zerver.lib.test_classes import WebhookTestCase
|
|
from zerver.lib.users import get_api_key
|
|
|
|
|
|
class DropboxHookTests(WebhookTestCase):
|
|
STREAM_NAME = "test"
|
|
URL_TEMPLATE = "/api/v1/external/dropbox?&api_key={api_key}&stream={stream}"
|
|
WEBHOOK_DIR_NAME = "dropbox"
|
|
|
|
def test_file_updated(self) -> None:
|
|
expected_topic = "Dropbox"
|
|
expected_message = "File has been updated on Dropbox!"
|
|
|
|
self.check_webhook(
|
|
"file_updated",
|
|
expected_topic,
|
|
expected_message,
|
|
content_type="application/x-www-form-urlencoded",
|
|
)
|
|
|
|
def test_verification_request(self) -> None:
|
|
self.subscribe(self.test_user, self.STREAM_NAME)
|
|
get_params = {"stream_name": self.STREAM_NAME, "api_key": get_api_key(self.test_user)}
|
|
result = self.client_get(self.url, get_params)
|
|
self.assert_json_error(result, "Missing 'challenge' argument", 400)
|
|
|
|
get_params["challenge"] = "9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E"
|
|
result = self.client_get(self.url, get_params)
|
|
|
|
self.assertEqual(result.status_code, 200)
|
|
self.assertEqual(result["Content-Type"], "text/plain; charset=UTF-8")
|
|
self.assert_in_response("9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E", result)
|