Files
galaxy/lib/galaxy_test/api/test_webhooks.py
T
Nicola Soranzo 0391cd4b62 Rename FooBarTestCase test classes as TestFooBar in API, framework, performance, Selenium and ToolShed tests
These are collected by pytest only because they are `unittest.TestCase` derived,
but normally pytest collects only test classes whose name starts with `Test`, see
https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-python_classes

Also:
- Some type annotations
2022-10-15 17:54:31 +01:00

36 lines
1.2 KiB
Python

from ._framework import ApiTestCase
class TestWebhooksApi(ApiTestCase):
def setUp(self):
super().setUp()
def test_get_all(self):
response = self._get("webhooks")
self._assert_status_code_is(response, 200)
webhook_objs = self._assert_are_webhooks(response)
ids = self._get_webhook_ids(webhook_objs)
for expected_id in ["history_test1", "history_test2", "masthead_test", "phdcomics", "trans_object", "xkcd"]:
assert expected_id in ids
def test_get_data(self):
response = self._get("webhooks/trans_object/data")
self._assert_status_code_is(response, 200)
self._assert_has_keys(response.json(), "username")
def _assert_are_webhooks(self, response):
response_list = response.json()
assert isinstance(response_list, list)
for obj in response_list:
self._assert_is_webhook(obj)
return response_list
def _assert_is_webhook(self, obj):
assert isinstance(obj, dict)
self._assert_has_keys(obj, "id", "type", "activate", "weight", "script", "styles", "config")
def _get_webhook_ids(self, webhook_objs):
names = [w.get("id") for w in webhook_objs]
return names