sintonia/api_client/tests/apcurl_test.py
Jonas L 30b3470a06
Better format enforcing ()
* Add shared python format-check target

* Add .format-check to api lint target

* Format api code with makefile format target

* Add .format-check to tools lint target

* Add .format-check to analyzer lint target

* Format analyzer code with makefile format target

* Add .format-check to celery lint target

* Add .format-check to api_client lint target

* Format api_client code with makefile format target

* Add .format-check to playout lint target

* Run CI linting in parallel

* Disable isort in pre-commit
2021-10-17 16:24:37 +02:00

33 lines
868 B
Python

import pytest
from api_clients.utils import ApcUrl, IncompleteUrl, UrlBadParam
@pytest.mark.parametrize(
"url, params, expected",
[
("one/two/three", {}, "one/two/three"),
("/testing/{key}", {"key": "aaa"}, "/testing/aaa"),
(
"/more/{key_a}/{key_b}/testing",
{"key_a": "aaa", "key_b": "bbb"},
"/more/aaa/bbb/testing",
),
],
)
def test_apc_url(url: str, params: dict, expected: str):
found = ApcUrl(url)
assert found.base_url == url
assert found.params(**params).url() == expected
def test_apc_url_bad_param():
url = ApcUrl("/testing/{key}")
with pytest.raises(UrlBadParam):
url.params(bad_key="testing")
def test_apc_url_incomplete():
url = ApcUrl("/{one}/{two}/three").params(two="testing")
with pytest.raises(IncompleteUrl):
url.url()