-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest_rounds.py
More file actions
73 lines (60 loc) · 1.85 KB
/
Copy pathtest_rounds.py
File metadata and controls
73 lines (60 loc) · 1.85 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
import responses
from client import Client
def test_all_calls_correct_url():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/rounds',
json={'success': True},
status=200
)
client = Client('http://127.0.0.1:4002/api')
client.rounds.all()
assert len(responses.calls) == 1
assert responses.calls[0].request.url == (
'http://127.0.0.1:4002/api/rounds'
)
def test_all_calls_correct_url_with_params():
responses.add(
responses.GET,
'http://127.0.0.1:4002/api/rounds',
json={'success': True},
status=200
)
client = Client('http://127.0.0.1:4002/api')
client.rounds.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/rounds?')
assert 'query_param1=value1' in url
assert 'query_param2=value2' in url
def test_show_calls_correct_url():
round_id = '12345'
responses.add(
responses.GET,
f'http://127.0.0.1:4002/api/rounds/{round_id}',
json={'success': True},
status=200
)
client = Client('http://127.0.0.1:4002/api')
client.rounds.show(round_id)
assert len(responses.calls) == 1
assert responses.calls[0].request.url == (
'http://127.0.0.1:4002/api/rounds/12345'
)
def test_validators_calls_correct_url():
round_id = '12345'
responses.add(
responses.GET,
f'http://127.0.0.1:4002/api/rounds/{round_id}/validators',
json={'success': True},
status=200
)
client = Client('http://127.0.0.1:4002/api')
client.rounds.validators(round_id)
assert len(responses.calls) == 1
assert responses.calls[0].request.url == (
'http://127.0.0.1:4002/api/rounds/12345/validators'
)