-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsync_test.py
169 lines (129 loc) · 5.47 KB
/
sync_test.py
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import os
import random
import pytest
from smsru_api.smsru import SmsRu
@pytest.fixture(scope='module')
def init_smsru():
return SmsRu(os.environ['API_KEY'])
@pytest.fixture
def get_number(init_smsru):
rnd_num = random.randint(9990000000, 9999999999)
result = init_smsru.send(str(rnd_num), message='Test message', debug=True)
return result['sms'][str(rnd_num)]['sms_id']
@pytest.mark.parametrize(
'number,expected', [
([str(random.randint(9990000000, 9999999999))], 'OK'),
([str(random.randint(9990000000, 9999999999)) for _ in range(1, 5)], 'OK'),
('322', 'ERROR')
]
)
def test_send(number, expected, init_smsru):
result = init_smsru.send(*number, message='Test message', debug=True)
assert type(result) == dict
assert result['status'] == "OK", result["status_text"]
for num in result['sms']:
assert result['sms'][num]['status'] == expected, result['sms'][num]["status_text"] if result['sms'][num]['status'] == 'ERROR' else None
def test_status(init_smsru, get_number):
result = init_smsru.status(get_number)
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
@pytest.mark.parametrize(
'number,expected', [
([str(random.randint(9990000000, 9999999999))], 'OK'),
([str(random.randint(9990000000, 9999999999)) for _ in range(1, 5)], 'OK'),
('322', 'ERROR')
]
)
def test_cost(number, expected, init_smsru):
result = init_smsru.cost(*number, message='Test message')
assert type(result) == dict
assert result['status'] == "OK", result["status_text"]
for num in result['sms']:
assert result['sms'][num]['status'] == expected, result['sms'][num]["status_text"] if result['sms'][num]['status'] == 'ERROR' else None
def test_balance(init_smsru):
result = init_smsru.balance()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
def test_limit(init_smsru):
result = init_smsru.limit()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
def test_free_limit(init_smsru):
result = init_smsru.free()
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
def test_senders(init_smsru):
result = init_smsru.senders()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
def test_stop_list_before_adding(init_smsru):
result = init_smsru.stop_list()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
@pytest.mark.parametrize(
'number,expected', [
('9000000000', 'OK'),
('9000000001', 'OK'),
('322', 'ERROR')
]
)
def test_add_stop_list(number, expected, init_smsru):
result = init_smsru.add_stop_list(number, 'Test')
assert type(result) == dict
assert result['status'] == expected, result["status_text"] if result['status'] == 'ERROR' else None
def test_stop_list_after_adding(init_smsru):
result = init_smsru.stop_list()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
@pytest.mark.parametrize(
'number,expected', [
('9000000000', 'OK'),
('9000000001', 'OK'),
('322', 'ERROR'),
('9000000002', 'OK')
]
)
def test_del_stop_list(number, expected, init_smsru):
result = init_smsru.del_stop_list(number)
assert type(result) == dict
assert result['status'] == expected, result["status_text"] if result['status'] == 'ERROR' else None
def test_stop_list_after_deleting(init_smsru):
result = init_smsru.stop_list()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
def test_callbacks_before_adding(init_smsru):
result = init_smsru.callbacks()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
@pytest.mark.parametrize(
'callback,expected', [
('http://test.net', 'OK'),
('https://test.get', 'OK'),
('test.bad', 'ERROR'),
('ftp://test.bad', 'ERROR')
]
)
def test_add_callback(callback, expected, init_smsru):
result = init_smsru.add_callback(callback)
assert type(result) == dict
assert result['status'] == expected, result["status_text"] if result['status'] == 'ERROR' else None
def test_callbacks_after_adding(init_smsru):
result = init_smsru.callbacks()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None
@pytest.mark.parametrize(
'callback,expected', [
('http://test.net', 'OK'),
('https://test.get', 'OK'),
('test.bad', 'ERROR'),
('rtp://test.bad', 'ERROR'),
('http://localhost', 'ERROR')
]
)
def test_del_callback(callback, expected, init_smsru):
result = init_smsru.del_callback(callback)
assert type(result) == dict
assert result['status'] == expected, result["status_text"] if result['status'] == 'ERROR' else None
def test_callbacks_after_deleting(init_smsru):
result = init_smsru.callbacks()
assert type(result) == dict
assert result['status'] == "OK", result["status_text"] if result['status'] == 'ERROR' else None