-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_client.py
26 lines (24 loc) · 1002 Bytes
/
test_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest
import respx
from datalab_api import DatalabClient
from httpx import Response
@respx.mock
def test_redirect_url(fake_ui_html, fake_info_json, fake_block_info_json):
fake_ui = respx.get("https://ui.datalab.industries").mock(
return_value=Response(200, content=fake_ui_html)
)
fake_info_api = respx.get("https://api.datalab.industries/info").mock(
return_value=Response(200, json=fake_info_json)
)
fake_block_info_api = respx.get("https://api.datalab.industries/info/blocks").mock(
return_value=Response(200, json=fake_block_info_json)
)
with pytest.warns(
UserWarning,
match="^Found API URL https://api.datalab.industries in HTML meta tag. Creating client with this URL instead.$",
):
client = DatalabClient("https://ui.datalab.industries")
assert fake_ui.called
assert fake_info_api.called
assert fake_block_info_api.called
assert client.datalab_api_url == "https://api.datalab.industries"