Skip to content

Commit b34066f

Browse files
committed
Removed some messagebird hlr related tests
1 parent aa359a7 commit b34066f

File tree

2 files changed

+2
-67
lines changed

2 files changed

+2
-67
lines changed

src/worker/webhooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ua_parser.user_agent_parser import Parse as ParseUserAgent
1212

1313
from src.schemas.messages import SendMethod
14-
from src.schemas.webhooks import BaseWebhook, MandrillWebhook
14+
from src.schemas.webhooks import BaseWebhook, MandrillWebhook, MessageBirdWebHook
1515

1616
main_logger = logging.getLogger('worker.webhooks')
1717

@@ -98,7 +98,7 @@ async def update_message_status(ctx, send_method: SendMethod, m: BaseWebhook, lo
9898
values=Values(message_id=message_id, status=m.status, ts=m.ts, extra=m.extra_json()),
9999
),
100100
]
101-
if hasattr(m, 'price_amount'):
101+
if isinstance(m, MessageBirdWebHook):
102102
cost = m.price_amount
103103
qs.append(
104104
glove.pg.execute_b('update messages set cost=:cost where id=:message_id', cost=cost, message_id=message_id)

tests/test_sms.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import re
32
from buildpg import V
43
from buildpg.clauses import Where
@@ -223,70 +222,6 @@ def test_send_messagebird(cli, tmpdir, dummy_server, worker, loop):
223222
assert dummy_server.log[1] == 'POST /messagebird/messages > 201'
224223

225224

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-
290225
def test_messagebird_webhook(cli, sync_db: SyncDb, dummy_server, worker, loop):
291226
data = {
292227
'uid': str(uuid4()),

0 commit comments

Comments
 (0)