Add an event if a user is archived

This adds a new type of event, 'archive_user', which stores the id of
the archived user and the id of the user who is doing the archiving.
This commit is contained in:
Katie Smith
2019-06-06 09:56:16 +01:00
parent 73b4aa4d85
commit f57f8641ad
4 changed files with 50 additions and 1 deletions
+16
View File
@@ -2,6 +2,7 @@ import uuid
from unittest.mock import ANY
from app.event_handlers import (
create_archive_user_event,
create_email_change_event,
create_mobile_number_change_event,
on_user_logged_in,
@@ -51,3 +52,18 @@ def test_create_mobile_number_change_event_calls_events_api(app_, mock_events):
'updated_by_id': updated_by_id,
'original_mobile_number': '07700900000',
'new_mobile_number': '07700900999'})
def test_create_archive_user_event_calls_events_api(app_, mock_events):
user_id = str(uuid.uuid4())
archived_by_id = str(uuid.uuid4())
with app_.test_request_context():
create_archive_user_event(user_id, archived_by_id)
mock_events.assert_called_with('archive_user',
{'browser_fingerprint':
{'browser': ANY, 'version': ANY, 'platform': ANY, 'user_agent_string': ''},
'ip_address': ANY,
'user_id': user_id,
'archived_by_id': archived_by_id})