forked from Vonage/vonage-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_verify.py
More file actions
101 lines (70 loc) · 3.5 KB
/
Copy pathtest_verify.py
File metadata and controls
101 lines (70 loc) · 3.5 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
from util import *
@responses.activate
def test_start_verification(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/json")
params = {"number": "447525856424", "brand": "MyApp"}
assert isinstance(client.start_verification(params), dict)
assert request_user_agent() == dummy_data.user_agent
assert "number=447525856424" in request_body()
assert "brand=MyApp" in request_body()
@responses.activate
def test_send_verification_request(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/json")
params = {"number": "447525856424", "brand": "MyApp"}
assert isinstance(client.send_verification_request(params), dict)
assert request_user_agent() == dummy_data.user_agent
assert "number=447525856424" in request_body()
assert "brand=MyApp" in request_body()
@responses.activate
def test_check_verification(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/check/json")
assert isinstance(
client.check_verification("8g88g88eg8g8gg9g90", code="123445"), dict
)
assert request_user_agent() == dummy_data.user_agent
assert "code=123445" in request_body()
assert "request_id=8g88g88eg8g8gg9g90" in request_body()
@responses.activate
def test_check_verification_request(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/check/json")
params = {"code": "123445", "request_id": "8g88g88eg8g8gg9g90"}
assert isinstance(client.check_verification_request(params), dict)
assert request_user_agent() == dummy_data.user_agent
assert "code=123445" in request_body()
assert "request_id=8g88g88eg8g8gg9g90" in request_body()
@responses.activate
def test_get_verification(client, dummy_data):
stub(responses.GET, "https://api.nexmo.com/verify/search/json")
assert isinstance(client.get_verification("xxx"), dict)
assert request_user_agent() == dummy_data.user_agent
assert "request_id=xxx" in request_query()
@responses.activate
def test_get_verification_request(client, dummy_data):
stub(responses.GET, "https://api.nexmo.com/verify/search/json")
assert isinstance(client.get_verification_request("xxx"), dict)
assert request_user_agent() == dummy_data.user_agent
assert "request_id=xxx" in request_query()
@responses.activate
def test_cancel_verification(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/control/json")
assert isinstance(client.cancel_verification("8g88g88eg8g8gg9g90"), dict)
assert request_user_agent() == dummy_data.user_agent
assert "cmd=cancel" in request_body()
assert "request_id=8g88g88eg8g8gg9g90" in request_body()
@responses.activate
def test_trigger_next_verification_event(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/control/json")
assert isinstance(
client.trigger_next_verification_event("8g88g88eg8g8gg9g90"), dict
)
assert request_user_agent() == dummy_data.user_agent
assert "cmd=trigger_next_event" in request_body()
assert "request_id=8g88g88eg8g8gg9g90" in request_body()
@responses.activate
def test_control_verification_request(client, dummy_data):
stub(responses.POST, "https://api.nexmo.com/verify/control/json")
params = {"cmd": "cancel", "request_id": "8g88g88eg8g8gg9g90"}
assert isinstance(client.control_verification_request(params), dict)
assert request_user_agent() == dummy_data.user_agent
assert "cmd=cancel" in request_body()
assert "request_id=8g88g88eg8g8gg9g90" in request_body()