-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest_api_nodes.py
More file actions
38 lines (32 loc) · 1 KB
/
test_api_nodes.py
File metadata and controls
38 lines (32 loc) · 1 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
import responses
from client import ArkClient
def test_api_nodes_calls_correct_url():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/api-nodes',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.api_nodes.all()
assert len(responses.calls) == 1
assert responses.calls[0].request.url == (
'http://127.0.0.1:4002/api/api-nodes'
)
def test_api_nodes_calls_correct_url_with_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/api-nodes',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.api_nodes.all({
'query_param1': 'value1',
'query_param2': 'value2',
})
assert len(responses.calls) == 1
url = responses.calls[0].request.url
assert url.startswith('http://127.0.0.1:4002/api/api-nodes?')
assert 'query_param1=value1' in url
assert 'query_param2=value2' in url