-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest_receipts.py
More file actions
47 lines (38 loc) · 1.44 KB
/
test_receipts.py
File metadata and controls
47 lines (38 loc) · 1.44 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
39
40
41
42
43
44
45
46
47
import responses
from client import ArkClient
def test_all_calls_correct_url():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/receipts',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.receipts.all()
assert len(responses.calls) == 1
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/receipts'
def test_all_calls_correct_url_with_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/receipts',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.receipts.all(query_param1='value1', query_param2='value2')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/receipts?')
assert 'query_param1=value1' in responses.calls[0].request.url
assert 'query_param2=value2' in responses.calls[0].request.url
def test_get_calls_correct_url():
transaction_hash = '12345'
responses.add(
responses.GET,
f'http://127.0.0.1:4002/api/receipts/{transaction_hash}',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.receipts.get(transaction_hash)
assert len(responses.calls) == 1
assert responses.calls[0].request.url == f'http://127.0.0.1:4002/api/receipts/{transaction_hash}'