chore: rename api_client to api-client (#1727)
This commit is contained in:
parent
e623c1f0df
commit
fef38fb131
20 changed files with 6 additions and 6 deletions
34
api-client/tests/apirequest_test.py
Normal file
34
api-client/tests/apirequest_test.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from libretime_api_client.utils import ApcUrl, ApiRequest
|
||||
|
||||
|
||||
def test_api_request_init():
|
||||
u = ApiRequest("request_name", ApcUrl("/test/ing"))
|
||||
assert u.name == "request_name"
|
||||
|
||||
|
||||
def test_api_request_call_json():
|
||||
return_value = {"ok": "ok"}
|
||||
|
||||
read = MagicMock()
|
||||
read.headers = {"content-type": "application/json"}
|
||||
read.json = MagicMock(return_value=return_value)
|
||||
|
||||
with patch("requests.get") as mock_method:
|
||||
mock_method.return_value = read
|
||||
request = ApiRequest("mm", ApcUrl("http://localhost/testing"))()
|
||||
assert request == return_value
|
||||
|
||||
|
||||
def test_api_request_call_html():
|
||||
return_value = "<html><head></head><body></body></html>"
|
||||
|
||||
read = MagicMock()
|
||||
read.headers = {"content-type": "application/html"}
|
||||
read.text = MagicMock(return_value=return_value)
|
||||
|
||||
with patch("requests.get") as mock_method:
|
||||
mock_method.return_value = read
|
||||
request = ApiRequest("mm", ApcUrl("http://localhost/testing"))()
|
||||
assert request.text() == return_value
|
Loading…
Add table
Add a link
Reference in a new issue