-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest_validators.py
More file actions
104 lines (81 loc) · 3.32 KB
/
test_validators.py
File metadata and controls
104 lines (81 loc) · 3.32 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import json
import responses
from client import ArkClient
def test_all_calls_correct_url_with_default_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.all()
assert len(responses.calls) == 1
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators?limit=100'
def test_all_calls_correct_url_with_passed_in_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.all(page=5, limit=69)
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators?')
assert 'page=5' in responses.calls[0].request.url
assert 'limit=69' in responses.calls[0].request.url
def test_all_calls_correct_url_with_additional_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators',
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.all(page=5, limit=69, orderBy="username")
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators?')
assert 'page=5' in responses.calls[0].request.url
assert 'limit=69' in responses.calls[0].request.url
assert 'orderBy=username' in responses.calls[0].request.url
def test_get_calls_correct_url():
validator_id = '12345'
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators/{}'.format(validator_id),
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.get(validator_id)
assert len(responses.calls) == 1
assert responses.calls[0].request.url == 'http://127.0.0.1:4002/api/validators/12345'
def test_blocks_calls_correct_url():
validator_id = '12345'
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators/{}/blocks'.format(validator_id),
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.blocks(validator_id, limit=100, orderBy='timestamp:desc')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/blocks?')
assert 'limit=100' in responses.calls[0].request.url
assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url
def test_voters_calls_correct_url():
validator_id = '12345'
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/validators/{}/voters'.format(validator_id),
json={'success': True},
status=200
)
client = ArkClient('http://127.0.0.1:4002/api')
client.validators.voters(validator_id, limit=100, orderBy='timestamp:desc')
assert len(responses.calls) == 1
assert responses.calls[0].request.url.startswith('http://127.0.0.1:4002/api/validators/12345/voters?')
assert 'limit=100' in responses.calls[0].request.url
assert 'orderBy=timestamp%3Adesc' in responses.calls[0].request.url