2017-12-18 01:56:03 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
2018-08-01 10:53:40 +02:00
|
|
|
from zerver.lib.users import get_api_key
|
2017-12-18 01:56:03 +01:00
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2017-12-18 01:56:03 +01:00
|
|
|
class DropboxHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'test'
|
2018-03-13 23:43:02 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/dropbox?&api_key={api_key}&stream={stream}"
|
2017-12-18 01:56:03 +01:00
|
|
|
FIXTURE_DIR_NAME = 'dropbox'
|
|
|
|
|
|
|
|
def test_file_updated(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "Dropbox"
|
|
|
|
expected_message = "File has been updated on Dropbox!"
|
2017-12-18 01:56:03 +01:00
|
|
|
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message('file_updated', expected_topic, expected_message,
|
2017-12-18 01:56:03 +01:00
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> str:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data("dropbox", fixture_name, file_type="json")
|
2017-12-18 01:56:03 +01:00
|
|
|
|
|
|
|
def test_verification_request(self) -> None:
|
|
|
|
self.subscribe(self.test_user, self.STREAM_NAME)
|
|
|
|
get_params = {'stream_name': self.STREAM_NAME,
|
|
|
|
'challenge': '9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E',
|
2018-08-01 10:53:40 +02:00
|
|
|
'api_key': get_api_key(self.test_user)}
|
2017-12-18 01:56:03 +01:00
|
|
|
result = self.client_get(self.url, get_params)
|
|
|
|
|
|
|
|
self.assert_in_response('9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E', result)
|