Removed contented updates the notifications stats table

- As before this is now driven from the notifications history table

- Removed from updates and create
- Signatures changes to removed unused params hits many files
- Also potential issue around rate limiting - we used to get the number sent per day from the stats table - which was a single row lookup, now we have to count this. This applies to EVERY API CALL. Probably not a good thing and should be addressed urgently.
This commit is contained in:
Martyn Inglis
2016-08-25 11:55:38 +01:00
parent 708f566c24
commit 893164ae40
12 changed files with 72 additions and 351 deletions

View File

@@ -68,43 +68,3 @@ def test_process_sms_response_returns_error_for_unknown_status():
success, error = process_sms_client_response(status='000', reference=str(uuid.uuid4()), client_name='Firetext')
assert success is None
assert error == "{} callback failed: status {} not found.".format('Firetext', '000')
def test_process_sms_response_updates_notification_stats_for_valid_request(notify_db,
notify_db_session,
sample_notification):
stats = NotificationStatistics.query.all()
assert len(stats) == 1
assert stats[0].sms_requested == 1
assert stats[0].sms_delivered == 0
assert stats[0].sms_failed == 0
success, error = process_sms_client_response(status='0', reference=str(sample_notification.id),
client_name='Firetext')
assert error is None
assert success == "{} callback succeeded. reference {} updated".format('Firetext', sample_notification.id)
stats = NotificationStatistics.query.all()
assert len(stats) == 1
assert stats[0].sms_requested == 1
assert stats[0].sms_delivered == 1
assert stats[0].sms_failed == 0
def test_process_sms_response_updates_notification_stats_for_valid_request_with_failed_status(notify_api,
notify_db,
notify_db_session,
sample_notification):
with notify_api.test_request_context():
stats = NotificationStatistics.query.all()
assert len(stats) == 1
assert stats[0].sms_requested == 1
assert stats[0].sms_delivered == 0
assert stats[0].sms_failed == 0
success, error = process_sms_client_response(status='1', reference=str(sample_notification.id),
client_name='Firetext')
assert success == "{} callback succeeded. reference {} updated".format('Firetext', sample_notification.id)
assert error is None
stats = NotificationStatistics.query.all()
assert len(stats) == 1
assert stats[0].sms_requested == 1
assert stats[0].sms_delivered == 0
assert stats[0].sms_failed == 1