|
1 | | -import logging |
2 | 1 | import re |
3 | 2 | from buildpg import V |
4 | 3 | from buildpg.clauses import Where |
@@ -223,70 +222,6 @@ def test_send_messagebird(cli, tmpdir, dummy_server, worker, loop): |
223 | 222 | assert dummy_server.log[1] == 'POST /messagebird/messages > 201' |
224 | 223 |
|
225 | 224 |
|
226 | | -def test_messagebird_no_hlr(cli, tmpdir, dummy_server, worker, caplog, loop): |
227 | | - data = { |
228 | | - 'uid': str(uuid4()), |
229 | | - 'company_code': 'foobar', |
230 | | - 'method': 'sms-messagebird', |
231 | | - 'main_template': 'this is a message', |
232 | | - 'recipients': [{'number': '07888888888'}], |
233 | | - } |
234 | | - r = cli.post('/send/sms/', json=data, headers={'Authorization': 'testing-key'}) |
235 | | - assert r.status_code == 201, r.text |
236 | | - assert worker.test_run() == 1 |
237 | | - assert [ |
238 | | - 'POST /messagebird/hlr > 201', |
239 | | - *['GET /messagebird/hlr/447888888888 > 200' for _ in range(60)], |
240 | | - ] == dummy_server.log |
241 | | - dummy_server.log = [] |
242 | | - assert 'No HLR result found for +447888888888 after 30 attempts' in caplog.messages |
243 | | - |
244 | | - |
245 | | -def test_messsagebird_no_hlr_found(cli, tmpdir, dummy_server, worker, caplog, loop): |
246 | | - data = { |
247 | | - 'uid': str(uuid4()), |
248 | | - 'company_code': 'foobar', |
249 | | - 'method': 'sms-messagebird', |
250 | | - 'main_template': 'this is a message', |
251 | | - 'recipients': [{'number': '07877777777'}], |
252 | | - } |
253 | | - r = cli.post('/send/sms/', json=data, headers={'Authorization': 'testing-key'}) |
254 | | - assert r.status_code == 201, r.text |
255 | | - assert worker.test_run() == 1 |
256 | | - assert [ |
257 | | - 'POST /messagebird/hlr > 201', |
258 | | - *['GET /messagebird/hlr/447877777777 > 404' for _ in range(60)], |
259 | | - ] == dummy_server.log |
260 | | - dummy_server.log = [] |
261 | | - assert 'No HLR result found for +447877777777 after 30 attempts' in caplog.messages |
262 | | - |
263 | | - |
264 | | -def test_messagebird_no_network(cli, tmpdir, dummy_server, worker, caplog, loop): |
265 | | - data = { |
266 | | - 'uid': str(uuid4()), |
267 | | - 'company_code': 'foobar', |
268 | | - 'method': 'sms-messagebird', |
269 | | - 'main_template': 'this is a message', |
270 | | - 'recipients': [{'number': '07777777777'}], |
271 | | - } |
272 | | - caplog.set_level(logging.INFO) |
273 | | - r = cli.post('/send/sms/', json=data, headers={'Authorization': 'testing-key'}) |
274 | | - assert r.status_code == 201, r.text |
275 | | - assert worker.test_run() == 1 |
276 | | - assert [ |
277 | | - 'POST /messagebird/hlr > 201', |
278 | | - 'GET /messagebird/hlr/447777777777 > 200', |
279 | | - 'GET /messagebird/hlr/447777777777 > 200', |
280 | | - 'GET /messagebird/pricing/sms/outbound > 200', |
281 | | - 'POST /messagebird/messages > 201', |
282 | | - ] == dummy_server.log |
283 | | - dummy_server.log = [] |
284 | | - assert ( |
285 | | - """found result for +447777777777 after 1 attempts {\n "status": "active",\n "network": "o2"\n}""" |
286 | | - in caplog.messages |
287 | | - ) |
288 | | - |
289 | | - |
290 | 225 | def test_messagebird_webhook(cli, sync_db: SyncDb, dummy_server, worker, loop): |
291 | 226 | data = { |
292 | 227 | 'uid': str(uuid4()), |
|
0 commit comments