From 02253d32c5a898669e128a1a4136c5ab1f57937c Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Tue, 17 Dec 2019 10:54:22 +0000 Subject: [PATCH] Update user_json test function Since we can't call the `api_user_active` fixture as a function with Pytest 5, the `user_json` function can be used instead. This updates the function to - Stop returning `max_failed_login_count` since this is not a field that gets returned from the api - Return fields as strings, not UUIDS, to match the format that api returns the data in - Provide a way to use this function to return a user with no permissions --- tests/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 55f84ec95..06ecf9c75 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -55,15 +55,14 @@ def user_json( failed_login_count=0, logged_in_at=None, state='active', - max_failed_login_count=3, platform_admin=False, current_session_id='1234', organisations=None, services=None ): - if not permissions: - permissions = {generate_uuid(): [ + if permissions is None: + permissions = {str(generate_uuid()): [ 'view_activity', 'send_texts', 'send_emails', @@ -73,6 +72,10 @@ def user_json( 'manage_settings', 'manage_api_keys', ]} + + if services is None: + services = [str(service_id) for service_id in permissions.keys()] + return { 'id': id_, 'name': name, @@ -84,11 +87,10 @@ def user_json( 'failed_login_count': failed_login_count, 'logged_in_at': logged_in_at or datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'), 'state': state, - 'max_failed_login_count': max_failed_login_count, 'platform_admin': platform_admin, 'current_session_id': current_session_id, 'organisations': organisations or [], - 'services': list(permissions.keys()) if services is None else services + 'services': services }