From 9636eaa0b0cbf209b2bee71e6ef8155b18ff9e04 Mon Sep 17 00:00:00 2001 From: Niko Lindroos Date: Thu, 22 Aug 2024 14:40:21 +0300 Subject: [PATCH] refactor: use enums with graphene KK-1108 --- children/schema.py | 17 +- children/tests/snapshots/snap_test_api.py | 1206 ++++---- .../snapshots/snap_test_notifications.py | 25 +- common/models.py | 10 +- common/tests/test_utils.py | 254 -- common/utils.py | 28 +- events/schema.py | 17 - events/tests/snapshots/snap_test_api.py | 2536 ++++++++++------- kukkuu/settings.py | 1 + messaging/schema.py | 5 - messaging/tests/snapshots/snap_test_api.py | 791 ++--- messaging/tests/test_api.py | 13 +- subscriptions/schema.py | 4 - users/schema.py | 6 +- users/tests/snapshots/snap_test_api.py | 491 ++-- venues/schema.py | 4 - 16 files changed, 2983 insertions(+), 2425 deletions(-) delete mode 100644 common/tests/test_utils.py diff --git a/children/schema.py b/children/schema.py index 8d3e4b13..d2968366 100644 --- a/children/schema.py +++ b/children/schema.py @@ -19,7 +19,7 @@ from children.notifications import NotificationType from common.schema import set_obj_languages_spoken_at_home -from common.utils import login_required, map_enums_to_values_in_kwargs, update_object +from common.utils import login_required, safe_test_and_get_enum_value, update_object from events.models import Event, Occurrence from kukkuu.exceptions import ( ApiUsageError, @@ -391,7 +391,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user if hasattr(user, "guardian"): @@ -421,7 +420,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs): first_name=guardian_data["first_name"], last_name=guardian_data["last_name"], phone_number=guardian_data.get("phone_number", ""), - language=guardian_data["language"], + language=safe_test_and_get_enum_value(guardian_data["language"]), email=guardian_data["email"], has_accepted_communication=guardian_data.get( "has_accepted_communication", False @@ -441,7 +440,9 @@ def mutate_and_get_payload(cls, root, info, **kwargs): child = Child.objects.create(**child_data) Relationship.objects.create( - type=relationship_data.get("type"), child=child, guardian=guardian + type=safe_test_and_get_enum_value(relationship_data.get("type")), + child=child, + guardian=guardian, ) set_obj_languages_spoken_at_home(info, child, languages) @@ -479,7 +480,6 @@ class Input(BaseNewChildInput): @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user if not hasattr(user, "guardian"): @@ -501,7 +501,9 @@ def mutate_and_get_payload(cls, root, info, **kwargs): child = Child.objects.create(**kwargs) Relationship.objects.create( - type=relationship_data.get("type"), child=child, guardian=user.guardian + type=safe_test_and_get_enum_value(relationship_data.get("type")), + child=child, + guardian=user.guardian, ) set_obj_languages_spoken_at_home(info, child, languages) @@ -523,7 +525,6 @@ class Input(BaseUpdateChildInput): @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): validate_child_data(kwargs) user = info.context.user @@ -561,7 +562,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user @@ -590,7 +590,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user child_global_id = kwargs.pop("child_id") diff --git a/children/tests/snapshots/snap_test_api.py b/children/tests/snapshots/snap_test_api.py index 285a9bb1..a5bd7bbd 100644 --- a/children/tests/snapshots/snap_test_api.py +++ b/children/tests/snapshots/snap_test_api.py @@ -4,211 +4,307 @@ from snapshottest import Snapshot + snapshots = Snapshot() -snapshots["test_active_internal_and_ticketmaster_enrolments 1"] = { - "data": { - "child": { - "activeInternalAndTicketSystemEnrolments": { - "edges": [ +snapshots['test_active_internal_and_ticketmaster_enrolments 1'] = { + 'data': { + 'child': { + 'activeInternalAndTicketSystemEnrolments': { + 'edges': [ { - "node": { - "__typename": "TicketmasterEnrolmentNode", - "createdAt": "2020-12-12T00:00:00+00:00", - "event": {"name": "1/5"}, + 'node': { + '__typename': 'TicketmasterEnrolmentNode', + 'createdAt': '2020-12-12T00:00:00+00:00', + 'event': { + 'name': '1/5' + } } }, { - "node": { - "__typename": "EnrolmentNode", - "occurrence": {"event": {"name": "2/5"}}, + 'node': { + '__typename': 'EnrolmentNode', + 'occurrence': { + 'event': { + 'name': '2/5' + } + } } }, { - "node": { - "__typename": "TicketmasterEnrolmentNode", - "createdAt": "2020-12-12T00:00:00+00:00", - "event": {"name": "3/5"}, + 'node': { + '__typename': 'TicketmasterEnrolmentNode', + 'createdAt': '2020-12-12T00:00:00+00:00', + 'event': { + 'name': '3/5' + } } }, { - "node": { - "__typename": "EnrolmentNode", - "occurrence": {"event": {"name": "4/5"}}, + 'node': { + '__typename': 'EnrolmentNode', + 'occurrence': { + 'event': { + 'name': '4/5' + } + } } }, { - "node": { - "__typename": "TicketmasterEnrolmentNode", - "createdAt": "2020-12-12T00:00:00+00:00", - "event": {"name": "5/5"}, + 'node': { + '__typename': 'TicketmasterEnrolmentNode', + 'createdAt': '2020-12-12T00:00:00+00:00', + 'event': { + 'name': '5/5' + } } - }, + } ] } } } } -snapshots["test_add_child_mutation 1"] = { - "data": { - "addChild": { - "child": {"birthyear": 2020, "name": "Pekka", "postalCode": "00820"} +snapshots['test_add_child_mutation 1'] = { + 'data': { + 'addChild': { + 'child': { + 'birthyear': 2020, + 'name': 'Pekka', + 'postalCode': '00820' + } } } } -snapshots["test_available_events_and_event_groups 1"] = { - "data": { - "child": { - "availableEventsAndEventGroups": { - "edges": [ +snapshots['test_available_events_and_event_groups 1'] = { + 'data': { + 'child': { + 'availableEventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventGroupNode", - "name": "this should be the first", + 'node': { + '__typename': 'EventGroupNode', + 'name': 'this should be the first' } }, { - "node": { - "__typename": "EventNode", - "name": "this should be the second", + 'node': { + '__typename': 'EventNode', + 'name': 'this should be the second' } }, { - "node": { - "__typename": "EventGroupNode", - "name": "this should be the third", + 'node': { + '__typename': 'EventGroupNode', + 'name': 'this should be the third' } }, { - "node": { - "__typename": "EventNode", - "name": "this should be the fourth", + 'node': { + '__typename': 'EventNode', + 'name': 'this should be the fourth' } - }, + } ] } } } } -snapshots["test_child_query 1"] = { - "data": { - "child": { - "birthyear": 2019, - "name": "Richard Hayes", - "postalCode": "57776", - "relationships": { - "edges": [ +snapshots['test_child_query 1'] = { + 'data': { + 'child': { + 'birthyear': 2019, + 'name': 'Richard Hayes', + 'postalCode': '57776', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Denise", - "lastName": "Thompson", - "phoneNumber": "001-206-575-0649x7638", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Denise', + 'lastName': 'Thompson', + 'phoneNumber': '001-206-575-0649x7638' }, - "type": "OTHER_RELATION", + 'type': 'OTHER_RELATION' } } ] - }, + } } } } -snapshots["test_child_query_not_own_child_project_user 1"] = { - "data": { - "child": { - "birthyear": 2019, - "name": "Richard Hayes", - "postalCode": "57776", - "relationships": { - "edges": [ +snapshots['test_child_query_not_own_child_project_user 1'] = { + 'data': { + 'child': { + 'birthyear': 2019, + 'name': 'Richard Hayes', + 'postalCode': '57776', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "blake64@example.net", - "firstName": "Timothy", - "lastName": "Baldwin", - "phoneNumber": "480.934.6697", + 'node': { + 'guardian': { + 'email': 'blake64@example.net', + 'firstName': 'Timothy', + 'lastName': 'Baldwin', + 'phoneNumber': '480.934.6697' }, - "type": "PARENT", + 'type': 'PARENT' } } ] - }, + } } } } -snapshots["test_children_offset_pagination[10-None] 1"] = { - "data": { - "children": { - "edges": [ - {"node": {"name": "1"}}, - {"node": {"name": "2"}}, - {"node": {"name": "3"}}, - {"node": {"name": "4"}}, - {"node": {"name": "5"}}, +snapshots['test_children_offset_pagination[10-None] 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'name': '1' + } + }, + { + 'node': { + 'name': '2' + } + }, + { + 'node': { + 'name': '3' + } + }, + { + 'node': { + 'name': '4' + } + }, + { + 'node': { + 'name': '5' + } + } ] } } } -snapshots["test_children_offset_pagination[2-2] 1"] = { - "data": {"children": {"edges": [{"node": {"name": "3"}}, {"node": {"name": "4"}}]}} +snapshots['test_children_offset_pagination[2-2] 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'name': '3' + } + }, + { + 'node': { + 'name': '4' + } + } + ] + } + } } -snapshots["test_children_offset_pagination[2-None] 1"] = { - "data": {"children": {"edges": [{"node": {"name": "1"}}, {"node": {"name": "2"}}]}} +snapshots['test_children_offset_pagination[2-None] 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'name': '1' + } + }, + { + 'node': { + 'name': '2' + } + } + ] + } + } } -snapshots["test_children_offset_pagination[None-2] 1"] = { - "data": { - "children": { - "edges": [ - {"node": {"name": "3"}}, - {"node": {"name": "4"}}, - {"node": {"name": "5"}}, +snapshots['test_children_offset_pagination[None-2] 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'name': '3' + } + }, + { + 'node': { + 'name': '4' + } + }, + { + 'node': { + 'name': '5' + } + } ] } } } -snapshots["test_children_offset_pagination[None-5] 1"] = { - "data": {"children": {"edges": []}} +snapshots['test_children_offset_pagination[None-5] 1'] = { + 'data': { + 'children': { + 'edges': [ + ] + } + } } -snapshots["test_children_project_filter 1"] = { - "data": {"children": {"edges": [{"node": {"name": "Only I should be returned"}}]}} +snapshots['test_children_project_filter 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'name': 'Only I should be returned' + } + } + ] + } + } } -snapshots["test_children_query_normal_user 1"] = { - "data": { - "children": { - "edges": [ - { - "node": { - "birthyear": 2019, - "name": "Richard Hayes", - "postalCode": "57776", - "relationships": { - "edges": [ +snapshots['test_children_query_normal_user 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'birthyear': 2019, + 'name': 'Richard Hayes', + 'postalCode': '57776', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Denise", - "lastName": "Thompson", - "phoneNumber": "001-206-575-0649x7638", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Denise', + 'lastName': 'Thompson', + 'phoneNumber': '001-206-575-0649x7638' }, - "type": "OTHER_RELATION", + 'type': 'OTHER_RELATION' } } ] - }, + } } } ] @@ -216,47 +312,87 @@ } } -snapshots["test_children_query_ordering 1"] = { - "data": { - "children": { - "edges": [ - {"node": {"createdAt": "2020-11-11T00:00:00+00:00", "name": ""}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": ""}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": "Alpha"}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": "Bravo"}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": "Bravo"}}, - {"node": {"createdAt": "2020-11-11T00:00:00+00:00", "name": "Charlie"}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": "Charlie"}}, - {"node": {"createdAt": "2020-12-12T00:00:00+00:00", "name": "Delta"}}, +snapshots['test_children_query_ordering 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'createdAt': '2020-11-11T00:00:00+00:00', + 'name': '' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': '' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'Alpha' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'Bravo' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'Bravo' + } + }, + { + 'node': { + 'createdAt': '2020-11-11T00:00:00+00:00', + 'name': 'Charlie' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'Charlie' + } + }, + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'Delta' + } + } ] } } } -snapshots["test_children_query_project_user 1"] = { - "data": { - "children": { - "edges": [ - { - "node": { - "birthyear": 2020, - "name": "Same project - Should be returned 1/1", - "postalCode": "73557", - "relationships": { - "edges": [ +snapshots['test_children_query_project_user 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'birthyear': 2020, + 'name': 'Same project - Should be returned 1/1', + 'postalCode': '73557', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "funderwood@example.com", - "firstName": "Blake", - "lastName": "Newton", - "phoneNumber": "497-963-8034x6697", + 'node': { + 'guardian': { + 'email': 'funderwood@example.com', + 'firstName': 'Blake', + 'lastName': 'Newton', + 'phoneNumber': '497-963-8034x6697' }, - "type": "PARENT", + 'type': 'PARENT' } } ] - }, + } } } ] @@ -264,521 +400,623 @@ } } -snapshots["test_children_query_project_user_and_guardian 1"] = { - "data": { - "children": { - "edges": [ - { - "node": { - "birthyear": 2021, - "name": "Not own child same project - Should be returned 3/3", - "postalCode": "11715", - "relationships": { - "edges": [ +snapshots['test_children_query_project_user_and_guardian 1'] = { + 'data': { + 'children': { + 'edges': [ + { + 'node': { + 'birthyear': 2021, + 'name': 'Not own child same project - Should be returned 3/3', + 'postalCode': '11715', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "anthonycross@example.com", - "firstName": "Sarah", - "lastName": "Larsen", - "phoneNumber": "4895817101", + 'node': { + 'guardian': { + 'email': 'anthonycross@example.com', + 'firstName': 'Sarah', + 'lastName': 'Larsen', + 'phoneNumber': '4895817101' }, - "type": "OTHER_RELATION", + 'type': 'OTHER_RELATION' } } ] - }, + } } }, { - "node": { - "birthyear": 2022, - "name": "Own child another project - Should be returned 2/3", - "postalCode": "34669", - "relationships": { - "edges": [ + 'node': { + 'birthyear': 2022, + 'name': 'Own child another project - Should be returned 2/3', + 'postalCode': '34669', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Michael", - "lastName": "Patton", - "phoneNumber": "235.857.7767x124", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Michael', + 'lastName': 'Patton', + 'phoneNumber': '235.857.7767x124' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } } }, { - "node": { - "birthyear": 2021, - "name": "Own child same project - Should be returned 1/3", - "postalCode": "06497", - "relationships": { - "edges": [ + 'node': { + 'birthyear': 2021, + 'name': 'Own child same project - Should be returned 1/3', + 'postalCode': '06497', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Michael", - "lastName": "Patton", - "phoneNumber": "235.857.7767x124", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Michael', + 'lastName': 'Patton', + 'phoneNumber': '235.857.7767x124' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } } - }, + } ] } } } -snapshots["test_children_total_count[None] 1"] = {"data": {"children": {"count": 5}}} +snapshots['test_children_total_count[None] 1'] = { + 'data': { + 'children': { + 'count': 5 + } + } +} -snapshots["test_children_total_count[first] 1"] = {"data": {"children": {"count": 5}}} +snapshots['test_children_total_count[first] 1'] = { + 'data': { + 'children': { + 'count': 5 + } + } +} -snapshots["test_children_total_count[limit] 1"] = {"data": {"children": {"count": 5}}} +snapshots['test_children_total_count[limit] 1'] = { + 'data': { + 'children': { + 'count': 5 + } + } +} -snapshots["test_delete_child_mutation 1"] = { - "data": {"deleteChild": {"__typename": "DeleteChildMutationPayload"}} +snapshots['test_delete_child_mutation 1'] = { + 'data': { + 'deleteChild': { + '__typename': 'DeleteChildMutationPayload' + } + } } -snapshots["test_get_available_events 1"] = { - "data": { - "child": { - "availableEvents": { - "edges": [ +snapshots['test_get_available_events 1'] = { + 'data': { + 'child': { + 'availableEvents': { + 'edges': [ { - "node": { - "createdAt": "2020-12-12T00:00:00+00:00", - "occurrences": { - "edges": [{"node": {"remainingCapacity": 46}}] - }, + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'occurrences': { + 'edges': [ + { + 'node': { + 'remainingCapacity': 46 + } + } + ] + } + } + } + ] + }, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2020-12-12T00:00:00+00:00' } } ] }, - "occurrences": {"edges": [{"node": {"time": "2020-12-12T00:00:00+00:00"}}]}, - "pastEvents": {"edges": []}, + 'pastEvents': { + 'edges': [ + ] + } } } } -snapshots["test_get_past_events 1"] = { - "data": { - "child": { - "availableEvents": {"edges": []}, - "occurrences": { - "edges": [ - {"node": {"time": "2020-12-11T22:59:00+00:00"}}, - {"node": {"time": "2020-12-11T23:01:00+00:00"}}, +snapshots['test_get_past_events 1'] = { + 'data': { + 'child': { + 'availableEvents': { + 'edges': [ ] }, - "pastEvents": { - "edges": [ + 'occurrences': { + 'edges': [ { - "node": { - "createdAt": "2020-12-12T00:00:00+00:00", - "name": "enrolled occurrence in the past", - "occurrences": { - "edges": [ - {"node": {"remainingCapacity": 12}}, - {"node": {"remainingCapacity": 13}}, - ] - }, + 'node': { + 'time': '2020-12-11T22:59:00+00:00' + } + }, + { + 'node': { + 'time': '2020-12-11T23:01:00+00:00' } } ] }, + 'pastEvents': { + 'edges': [ + { + 'node': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'name': 'enrolled occurrence in the past', + 'occurrences': { + 'edges': [ + { + 'node': { + 'remainingCapacity': 12 + } + }, + { + 'node': { + 'remainingCapacity': 13 + } + } + ] + } + } + } + ] + } } } } -snapshots["test_get_past_events_including_external_ticket_system_events 1"] = { - "data": { - "child": { - "pastEvents": { - "edges": [ - {"node": {"name": "Expected as 1/4"}}, - {"node": {"name": "Expected as 2/4"}}, - {"node": {"name": "Expected as 3/4"}}, - {"node": {"name": "Expected as 4/4"}}, +snapshots['test_get_past_events_including_external_ticket_system_events 1'] = { + 'data': { + 'child': { + 'pastEvents': { + 'edges': [ + { + 'node': { + 'name': 'Expected as 1/4' + } + }, + { + 'node': { + 'name': 'Expected as 2/4' + } + }, + { + 'node': { + 'name': 'Expected as 3/4' + } + }, + { + 'node': { + 'name': 'Expected as 4/4' + } + } ] } } } } -snapshots["test_submit_children_and_guardian 1"] = { - "data": { - "submitChildrenAndGuardian": { - "children": [ +snapshots['test_submit_children_and_guardian 1'] = { + 'data': { + 'submitChildrenAndGuardian': { + 'children': [ { - "birthyear": 2020, - "name": "Matti", - "postalCode": "00840", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Matti', + 'postalCode': '00840', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } }, { - "birthyear": 2020, - "name": "Jussi", - "postalCode": "00820", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Jussi', + 'postalCode': '00820', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": None, + 'type': None } } ] - }, - }, + } + } ], - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "languagesSpokenAtHome": { - "edges": [ - {"node": {"alpha3Code": "swe"}}, - {"node": {"alpha3Code": "fin"}}, + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'languagesSpokenAtHome': { + 'edges': [ + { + 'node': { + 'alpha3Code': 'swe' + } + }, + { + 'node': { + 'alpha3Code': 'fin' + } + } ] }, - "lastName": "Guardian", - "phoneNumber": "777-777777", - }, + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' + } } } } -snapshots["test_submit_children_and_guardian_with_falsy_email[None] 1"] = { - "data": { - "submitChildrenAndGuardian": { - "children": [ +snapshots['test_submit_children_and_guardian_with_falsy_email[None] 1'] = { + 'data': { + 'submitChildrenAndGuardian': { + 'children': [ { - "birthyear": 2020, - "name": "Matti", - "postalCode": "00840", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Matti', + 'postalCode': '00840', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } }, { - "birthyear": 2020, - "name": "Jussi", - "postalCode": "00820", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Jussi', + 'postalCode': '00820', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": None, + 'type': None } } ] - }, - }, + } + } ], - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "languagesSpokenAtHome": {"edges": []}, - "lastName": "Guardian", - "phoneNumber": "777-777777", - }, + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'languagesSpokenAtHome': { + 'edges': [ + ] + }, + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' + } } } } -snapshots["test_submit_children_and_guardian_with_falsy_email[] 1"] = { - "data": { - "submitChildrenAndGuardian": { - "children": [ +snapshots['test_submit_children_and_guardian_with_falsy_email[] 1'] = { + 'data': { + 'submitChildrenAndGuardian': { + 'children': [ { - "birthyear": 2020, - "name": "Matti", - "postalCode": "00840", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Matti', + 'postalCode': '00840', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } }, { - "birthyear": 2020, - "name": "Jussi", - "postalCode": "00820", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Jussi', + 'postalCode': '00820', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": None, + 'type': None } } ] - }, - }, + } + } ], - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "languagesSpokenAtHome": {"edges": []}, - "lastName": "Guardian", - "phoneNumber": "777-777777", - }, + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'languagesSpokenAtHome': { + 'edges': [ + ] + }, + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' + } } } } -snapshots["test_submit_children_and_guardian_with_user_email 1"] = { - "data": { - "submitChildrenAndGuardian": { - "children": [ +snapshots['test_submit_children_and_guardian_with_user_email 1'] = { + 'data': { + 'submitChildrenAndGuardian': { + 'children': [ { - "birthyear": 2020, - "name": "Matti", - "postalCode": "00840", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Matti', + 'postalCode': '00840', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } }, { - "birthyear": 2020, - "name": "Jussi", - "postalCode": "00820", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Jussi', + 'postalCode': '00820', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": None, + 'type': None } } ] - }, - }, + } + } ], - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "languagesSpokenAtHome": {"edges": []}, - "lastName": "Guardian", - "phoneNumber": "777-777777", - }, + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'languagesSpokenAtHome': { + 'edges': [ + ] + }, + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' + } } } } -snapshots["test_submit_children_and_guardian_without_email 1"] = { - "data": { - "submitChildrenAndGuardian": { - "children": [ +snapshots['test_submit_children_and_guardian_without_email 1'] = { + 'data': { + 'submitChildrenAndGuardian': { + 'children': [ { - "birthyear": 2020, - "name": "Matti", - "postalCode": "00840", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Matti', + 'postalCode': '00840', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } }, { - "birthyear": 2020, - "name": "Jussi", - "postalCode": "00820", - "relationships": { - "edges": [ + 'birthyear': 2020, + 'name': 'Jussi', + 'postalCode': '00820', + 'relationships': { + 'edges': [ { - "node": { - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "lastName": "Guardian", - "phoneNumber": "777-777777", + 'node': { + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' }, - "type": None, + 'type': None } } ] - }, - }, + } + } ], - "guardian": { - "email": "michellewalker@example.net", - "firstName": "Gulle", - "languagesSpokenAtHome": {"edges": []}, - "lastName": "Guardian", - "phoneNumber": "777-777777", - }, + 'guardian': { + 'email': 'michellewalker@example.net', + 'firstName': 'Gulle', + 'languagesSpokenAtHome': { + 'edges': [ + ] + }, + 'lastName': 'Guardian', + 'phoneNumber': '777-777777' + } } } } -snapshots["test_upcoming_events_and_event_groups 1"] = { - "data": { - "child": { - "upcomingEventsAndEventGroups": { - "edges": [ +snapshots['test_upcoming_events_and_event_groups 1'] = { + 'data': { + 'child': { + 'upcomingEventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventGroupNode", - "canChildEnroll": True, - "name": "This should be the 1/8", + 'node': { + '__typename': 'EventGroupNode', + 'canChildEnroll': True, + 'name': 'This should be the 1/8' } }, { - "node": { - "__typename": "EventNode", - "canChildEnroll": True, - "name": "This should be 2/8", + 'node': { + '__typename': 'EventNode', + 'canChildEnroll': True, + 'name': 'This should be 2/8' } }, { - "node": { - "__typename": "EventNode", - "canChildEnroll": True, - "name": "This should be 3/8", + 'node': { + '__typename': 'EventNode', + 'canChildEnroll': True, + 'name': 'This should be 3/8' } }, { - "node": { - "__typename": "EventNode", - "canChildEnroll": True, - "name": "This should be 4/8", + 'node': { + '__typename': 'EventNode', + 'canChildEnroll': True, + 'name': 'This should be 4/8' } }, { - "node": { - "__typename": "EventNode", - "canChildEnroll": True, - "name": "This should be 5/8", + 'node': { + '__typename': 'EventNode', + 'canChildEnroll': True, + 'name': 'This should be 5/8' } }, { - "node": { - "__typename": "EventGroupNode", - "canChildEnroll": True, - "name": "This should be 6/8", + 'node': { + '__typename': 'EventGroupNode', + 'canChildEnroll': True, + 'name': 'This should be 6/8' } }, { - "node": { - "__typename": "EventNode", - "canChildEnroll": False, - "name": "This should be 7/8", + 'node': { + '__typename': 'EventNode', + 'canChildEnroll': False, + 'name': 'This should be 7/8' } }, { - "node": { - "__typename": "EventGroupNode", - "canChildEnroll": False, - "name": "This should be 8/8", + 'node': { + '__typename': 'EventGroupNode', + 'canChildEnroll': False, + 'name': 'This should be 8/8' } - }, + } ] } } } } -snapshots["test_update_child_mutation 1"] = { - "data": { - "updateChild": { - "child": {"birthyear": 2021, "name": "Matti", "postalCode": "00840"} +snapshots['test_update_child_mutation 1'] = { + 'data': { + 'updateChild': { + 'child': { + 'birthyear': 2021, + 'name': 'Matti', + 'postalCode': '00840' + } } } } -snapshots["test_update_child_mutation_should_have_no_required_fields 1"] = { - "data": { - "updateChild": { - "child": {"birthyear": 2021, "name": "Derek Perry", "postalCode": "70117"} +snapshots['test_update_child_mutation_should_have_no_required_fields 1'] = { + 'data': { + 'updateChild': { + 'child': { + 'birthyear': 2021, + 'name': 'Derek Perry', + 'postalCode': '70117' + } } } } diff --git a/children/tests/snapshots/snap_test_notifications.py b/children/tests/snapshots/snap_test_notifications.py index 4d1dc106..b3bfae01 100644 --- a/children/tests/snapshots/snap_test_notifications.py +++ b/children/tests/snapshots/snap_test_notifications.py @@ -4,36 +4,37 @@ from snapshottest import Snapshot + snapshots = Snapshot() -snapshots["test_signup_notification 1"] = [ - """kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| +snapshots['test_signup_notification 1'] = [ + '''kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| SIGNUP-notifikaation sisältö tekstimuodossa. Lapset: [, ] Huoltaja: Gulle Guardian (michellewalker@example.net) -Unsubscribe: http://localhost:3000/fi/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8""" +Unsubscribe: http://localhost:3000/fi/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8''' ] -snapshots["test_signup_notification_language[EN] 1"] = [ - """kukkuu@example.com|['michellewalker@example.net']|SIGNUP notification subject| +snapshots['test_signup_notification_language[EN] 1'] = [ + '''kukkuu@example.com|['michellewalker@example.net']|SIGNUP notification subject| SIGNUP notification body text. Children: [, ] Guardian: Gulle Guardian (michellewalker@example.net) -Unsubscribe: http://localhost:3000/en/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8""" +Unsubscribe: http://localhost:3000/en/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8''' ] -snapshots["test_signup_notification_language[FI] 1"] = [ - """kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| +snapshots['test_signup_notification_language[FI] 1'] = [ + '''kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| SIGNUP-notifikaation sisältö tekstimuodossa. Lapset: [, ] Huoltaja: Gulle Guardian (michellewalker@example.net) -Unsubscribe: http://localhost:3000/fi/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8""" +Unsubscribe: http://localhost:3000/fi/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8''' ] -snapshots["test_signup_notification_language[SV] 1"] = [ - """kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| +snapshots['test_signup_notification_language[SV] 1'] = [ + '''kukkuu@example.com|['michellewalker@example.net']|SIGNUP-notifikaation aihe| SIGNUP-notifikaation sisältö tekstimuodossa. Lapset: [, ] Huoltaja: Gulle Guardian (michellewalker@example.net) -Unsubscribe: http://localhost:3000/sv/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8""" +Unsubscribe: http://localhost:3000/sv/profile/subscriptions?authToken=a1b2c3d4e5f6g7h8''' ] diff --git a/common/models.py b/common/models.py index 9770aa72..d33698f9 100644 --- a/common/models.py +++ b/common/models.py @@ -7,7 +7,7 @@ from parler.managers import TranslatableQuerySet as ParlerTranslatableQuerySet from parler.models import TranslatableModel as ParlerTranslatableModel -from common.utils import map_enums_to_values_in_kwargs +from common.utils import safe_test_and_get_enum_value from kukkuu.exceptions import MissingDefaultTranslationError @@ -30,7 +30,6 @@ class Meta: class TranslatableQuerySet(ParlerTranslatableQuerySet): @transaction.atomic - @map_enums_to_values_in_kwargs def create_translatable_object(self, **kwargs): translations = kwargs.pop("translations") obj = self.create(**kwargs) @@ -47,13 +46,16 @@ class Meta: @transaction.atomic def create_or_update_translations(self, translations): if settings.LANGUAGE_CODE not in [ - translation["language_code"] for translation in translations + safe_test_and_get_enum_value(translation["language_code"]) + for translation in translations ]: raise MissingDefaultTranslationError("Default translation is missing") self.clear_translations() for translation in translations: translation = deepcopy(translation) - language_code = translation.pop("language_code") + language_code = safe_test_and_get_enum_value( + translation.pop("language_code") + ) if language_code not in settings.PARLER_SUPPORTED_LANGUAGE_CODES: continue self.create_translation(language_code=language_code, **translation) diff --git a/common/tests/test_utils.py b/common/tests/test_utils.py deleted file mode 100644 index 670a91be..00000000 --- a/common/tests/test_utils.py +++ /dev/null @@ -1,254 +0,0 @@ -import enum -from enum import auto - -import graphene -import pytest - -from common.utils import ( - deepfix_enum_values, - is_enum_value, - map_enums_to_values_in_kwargs, -) - - -class _OrderEnum(graphene.Enum): - FIRST = 1 - SECOND = 2 - - -class _TestEnum(enum.Enum): - TEST = "test_1" - TEST_2 = 2 - - -class _TestGrapheneEnum(graphene.Enum): - FIRST_ENUM_NAME = "FIRST_ENUM_VALUE" - ENUM_NAME_1 = "ENUM_VALUE_1" - ENUM_NAME_2 = "ENUM_VALUE_2" - LAST_ENUM_NAME = "LAST_ENUM_VALUE" - - -class _TestGrapheneEnumAuto(graphene.Enum): - _123 = auto() - test = auto() - - -@pytest.mark.parametrize( - "value", - [ - _TestEnum.TEST, - _TestEnum.TEST_2, - _TestGrapheneEnum.FIRST_ENUM_NAME, - _TestGrapheneEnum.ENUM_NAME_1, - _TestGrapheneEnum.ENUM_NAME_2, - _TestGrapheneEnum.LAST_ENUM_NAME, - _TestGrapheneEnumAuto._123, - _TestGrapheneEnumAuto.test, - ], -) -def test_is_enum_value_true(value): - assert is_enum_value(value) is True - - -@pytest.mark.parametrize( - "value", - [ - None, - 0, - 1, - 2, - "0", - "1", - "2", - "FIRST_ENUM_VALUE", - "ENUM_VALUE_1", - "ENUM_VALUE_2", - "LAST_ENUM_VALUE", - ], -) -def test_is_enum_value_false(value): - assert is_enum_value(value) is False - - -@pytest.mark.parametrize( - "input", - [ - None, - 0, - 1, - 2, - "0", - "1", - "2", - "FIRST_ENUM_VALUE", - "ENUM_VALUE_1", - "ENUM_VALUE_2", - "LAST_ENUM_VALUE", - {1, 2, 3, "test", 2}, - (1, 2, 3, "test", 2), - [1, 2, 3, "test", 2], - (1, [2, {3: {4, (11, (12,), 13, None, "test")}}]), - ], -) -def test_deepfix_enum_values_unchanged(input): - assert deepfix_enum_values(input) == input - - -def test_deepfix_enum_values_changes_output_but_not_input(): - """ - Test that the input is not modified even when the output is. - """ - input = {_TestEnum.TEST: "test"} - assert deepfix_enum_values(input) == {"test_1": "test"} - assert input == {_TestEnum.TEST: "test"} - - -@pytest.mark.parametrize( - "input,expected_output", - [ - (_TestEnum.TEST, "test_1"), - (_TestEnum.TEST_2, 2), - (_TestGrapheneEnum.FIRST_ENUM_NAME, "FIRST_ENUM_VALUE"), - (_TestGrapheneEnum.ENUM_NAME_1, "ENUM_VALUE_1"), - (_TestGrapheneEnum.ENUM_NAME_2, "ENUM_VALUE_2"), - (_TestGrapheneEnum.LAST_ENUM_NAME, "LAST_ENUM_VALUE"), - (_TestGrapheneEnumAuto._123, 1), - (_TestGrapheneEnumAuto.test, 2), - ( - [_TestGrapheneEnumAuto.test, _TestEnum.TEST, 123, "TEST"], - [2, "test_1", 123, "TEST"], - ), - ({_TestEnum.TEST: "test"}, {"test_1": "test"}), - ( - { - _TestEnum.TEST: [ - "test", - "123", - 1234, - _TestGrapheneEnumAuto.test, - ( - _TestEnum.TEST_2, - _TestGrapheneEnum.ENUM_NAME_1, - _TestGrapheneEnumAuto.test, - ), - { - _TestGrapheneEnumAuto.test, - "not_enum", - _TestEnum.TEST, - _TestEnum.TEST_2, - }, - { - "not_enum_key": "not_enum_value", - _TestEnum.TEST: _TestGrapheneEnumAuto.test, - }, - (_TestGrapheneEnumAuto.test, _TestEnum.TEST, "not_enum"), - [_TestEnum.TEST, _TestGrapheneEnumAuto.test], - _TestGrapheneEnumAuto.test, - ], - _TestGrapheneEnum.ENUM_NAME_1: { - _TestEnum.TEST_2, - _TestGrapheneEnumAuto.test, - _TestGrapheneEnum.ENUM_NAME_1, - }, - }, - { - "test_1": [ - "test", - "123", - 1234, - 2, - (2, "ENUM_VALUE_1", 2), - {2, "not_enum", "test_1"}, - {"not_enum_key": "not_enum_value", "test_1": 2}, - (2, "test_1", "not_enum"), - ["test_1", 2], - 2, - ], - "ENUM_VALUE_1": { - 2, - 2, - "ENUM_VALUE_1", - }, - }, - ), - ( - ( - _TestEnum.TEST, - [ - _TestEnum.TEST_2, - { - _TestGrapheneEnum.FIRST_ENUM_NAME: { - _TestGrapheneEnum.ENUM_NAME_1, - (_TestGrapheneEnum.ENUM_NAME_2,), - _TestGrapheneEnum.LAST_ENUM_NAME, - } - }, - ], - ), - ( - "test_1", - [ - 2, - { - "FIRST_ENUM_VALUE": { - "ENUM_VALUE_1", - ("ENUM_VALUE_2",), - "LAST_ENUM_VALUE", - } - }, - ], - ), - ), - ], -) -def test_deepfix_enum_values_changed(input, expected_output): - assert deepfix_enum_values(input) == expected_output - - -@pytest.mark.parametrize("args", [(), ("testing", 1234, ["a", 1, 2, "b"])]) -@pytest.mark.parametrize( - "kwargs,expected_kwargs", - [ - ({"x": _OrderEnum.FIRST}, {"x": 1}), - ({"x": _OrderEnum.SECOND}, {"x": 2}), - ({"x": _OrderEnum.FIRST, "y": _OrderEnum.SECOND}, {"x": 1, "y": 2}), - ( - { - "order_priority_reverse_mapping": [ - { - 1: [_OrderEnum.SECOND, _OrderEnum.FIRST], - 2: [_OrderEnum.FIRST, _OrderEnum.SECOND], - }, - "test", - 1, - 2, - 3, - _OrderEnum.FIRST, - _OrderEnum.SECOND, - 3, - ] - }, - { - "order_priority_reverse_mapping": [ - { - 1: [2, 1], - 2: [1, 2], - }, - "test", - 1, - 2, - 3, - 1, - 2, - 3, - ] - }, - ), - ], -) -def test_map_enums_to_values_in_kwargs(args, kwargs, expected_kwargs): - @map_enums_to_values_in_kwargs - def method(*args, **kwargs): - return (args, kwargs) - - assert method(*args, **kwargs) == (args, expected_kwargs) diff --git a/common/utils.py b/common/utils.py index 0b79ae29..495faac5 100644 --- a/common/utils.py +++ b/common/utils.py @@ -24,30 +24,8 @@ def is_enum_value(value): return type(type(value)) is enum.EnumMeta -def deepfix_enum_values(data): - """ - Fix enum values recursively in/out of dictionaries, lists, sets, and tuples. - """ - if isinstance(data, dict): - return {deepfix_enum_values(k): deepfix_enum_values(v) for k, v in data.items()} - elif isinstance(data, (list, set, tuple)): - return type(data)(deepfix_enum_values(v) for v in data) - elif is_enum_value(data): - return data.value - else: - return data - - -def map_enums_to_values_in_kwargs(method): - """ - Decorator that maps enums to their values in keyword arguments. - """ - - def wrapper(*args, **kwargs): - fixed_kwargs = deepfix_enum_values(kwargs) - return method(*args, **fixed_kwargs) - - return wrapper +def safe_test_and_get_enum_value(enum_value): + return enum_value.value if is_enum_value(enum_value) else enum_value def update_object(obj, data): @@ -56,7 +34,7 @@ def update_object(obj, data): for k, v in data.items(): if v is None and not obj.__class__._meta.get_field(k).null: raise DataValidationError(f"{k} cannot be null.") - setattr(obj, k, v) + setattr(obj, k, safe_test_and_get_enum_value(v)) obj.save() diff --git a/events/schema.py b/events/schema.py index e80d91ae..e625b13f 100644 --- a/events/schema.py +++ b/events/schema.py @@ -23,7 +23,6 @@ get_node_id_from_global_id, get_obj_if_user_can_administer, login_required, - map_enums_to_values_in_kwargs, project_user_required, update_object, update_object_with_translations, @@ -644,7 +643,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event_id = get_node_id_from_global_id(kwargs.get("event_id"), "EventNode") given_passwords = kwargs.get("passwords") @@ -732,7 +730,6 @@ class Input: @classmethod @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event_id = get_node_id_from_global_id(kwargs.get("event_id"), "EventNode") child_id = get_node_id_from_global_id(kwargs.get("child_id"), "ChildNode") @@ -774,7 +771,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): original_kwargs = deepcopy(kwargs) @@ -843,7 +839,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): original_kwargs = deepcopy(kwargs) @@ -893,7 +888,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event = get_obj_if_user_can_administer(info, kwargs["id"], Event) event.delete() @@ -913,7 +907,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): occurrence_id = from_global_id(kwargs["occurrence_id"])[1] child_id = from_global_id(kwargs["child_id"])[1] @@ -947,7 +940,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): occurrence_id = from_global_id(kwargs["occurrence_id"])[1] child_id = from_global_id(kwargs["child_id"])[1] @@ -988,7 +980,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): if "attended" not in kwargs: raise DataValidationError('"attended" is required.') @@ -1026,7 +1017,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): original_kwargs = deepcopy(kwargs) @@ -1070,7 +1060,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): original_kwargs = deepcopy(kwargs) occurrence = get_obj_if_user_can_administer(info, kwargs.pop("id"), Occurrence) @@ -1116,7 +1105,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): occurrence = get_obj_if_user_can_administer(info, kwargs["id"], Occurrence) log_text = ( @@ -1139,7 +1127,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event = get_obj_if_user_can_administer(info, kwargs["id"], Event) user = info.context.user @@ -1183,7 +1170,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user @@ -1215,7 +1201,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event_group = get_obj_if_user_can_administer(info, kwargs.pop("id"), EventGroup) user = info.context.user @@ -1245,7 +1230,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event_group = get_obj_if_user_can_administer(info, kwargs["id"], EventGroup) user = info.context.user @@ -1268,7 +1252,6 @@ class Input: @classmethod @project_user_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): event_group = get_obj_if_user_can_administer(info, kwargs["id"], EventGroup) user = info.context.user diff --git a/events/tests/snapshots/snap_test_api.py b/events/tests/snapshots/snap_test_api.py index c32d8915..0f674639 100644 --- a/events/tests/snapshots/snap_test_api.py +++ b/events/tests/snapshots/snap_test_api.py @@ -4,619 +4,835 @@ from snapshottest import Snapshot + snapshots = Snapshot() -snapshots["test_add_event_group[model_perm] 1"] = { - "data": { - "addEventGroup": { - "eventGroup": { - "image": "", - "imageAltText": "Image alt text", - "project": {"year": 2020}, - "publishedAt": None, - "translations": [ +snapshots['test_add_event_group[model_perm] 1'] = { + 'data': { + 'addEventGroup': { + 'eventGroup': { + 'image': '', + 'imageAltText': 'Image alt text', + 'project': { + 'year': 2020 + }, + 'publishedAt': None, + 'translations': [ { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event group test", - "shortDescription": "Short desc", + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'FI', + 'name': 'Event group test', + 'shortDescription': 'Short desc' } - ], + ] } } } } -snapshots["test_add_event_group[object_perm] 1"] = { - "data": { - "addEventGroup": { - "eventGroup": { - "image": "", - "imageAltText": "Image alt text", - "project": {"year": 2020}, - "publishedAt": None, - "translations": [ +snapshots['test_add_event_group[object_perm] 1'] = { + 'data': { + 'addEventGroup': { + 'eventGroup': { + 'image': '', + 'imageAltText': 'Image alt text', + 'project': { + 'year': 2020 + }, + 'publishedAt': None, + 'translations': [ { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event group test", - "shortDescription": "Short desc", + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'FI', + 'name': 'Event group test', + 'shortDescription': 'Short desc' } - ], + ] } } } } -snapshots["test_add_event_project_user 1"] = { - "data": { - "addEvent": { - "event": { - "capacityPerOccurrence": 30, - "duration": 1000, - "image": "", - "imageAltText": "Image alt text", - "participantsPerInvite": "FAMILY", - "project": {"year": 2020}, - "publishedAt": None, - "readyForEventGroupPublishing": False, - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ - { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event test", - "shortDescription": "Short desc", - } - ], - } +snapshots['test_add_event_project_user 1'] = { + 'data': { + 'addEvent': { + 'event': None } - } + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 7, + 'line': 18 + } + ], + 'message': "Enum 'EventParticipantsPerInvite' cannot represent value: 'EnumMeta.FAMILY'", + 'path': [ + 'addEvent', + 'event', + 'participantsPerInvite' + ] + } + ] } -snapshots["test_add_occurrence_project_user 1"] = { - "data": { - "addOccurrence": { - "occurrence": { - "capacity": 35, - "capacityOverride": None, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "FI", - "ticketSystem": {"type": "INTERNAL"}, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, +snapshots['test_add_occurrence_project_user 1'] = { + 'data': { + 'addOccurrence': { + 'occurrence': { + 'capacity': 35, + 'capacityOverride': None, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'FI', + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_add_occurrence_ticket_system_url 1"] = { - "data": { - "addOccurrence": { - "occurrence": { - "capacity": 9, - "capacityOverride": None, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "FI", - "ticketSystem": {"type": "TICKETMASTER", "url": "https://example.com"}, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, +snapshots['test_add_occurrence_ticket_system_url 1'] = { + 'data': { + 'addOccurrence': { + 'occurrence': { + 'capacity': 9, + 'capacityOverride': None, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'FI', + 'ticketSystem': { + 'type': 'TICKETMASTER', + 'url': 'https://example.com' + }, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_add_ticketmaster_event 1"] = { - "data": {"addEvent": {"event": {"ticketSystem": {"type": "TICKETMASTER"}}}} +snapshots['test_add_ticketmaster_event 1'] = { + 'data': { + 'addEvent': { + 'event': { + 'ticketSystem': None + } + } + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 7, + 'line': 5 + } + ], + 'message': 'Invalid ticket system "EnumMeta.TICKETMASTER".', + 'path': [ + 'addEvent', + 'event', + 'ticketSystem' + ] + } + ] } -snapshots["test_assign_ticket_system_password 1"] = { - "data": { - "assignTicketSystemPassword": { - "child": {"name": "Luis Lawson"}, - "event": {"name": "Dog hospital number."}, - "password": "the correct password", +snapshots['test_assign_ticket_system_password 1'] = { + 'data': { + 'assignTicketSystemPassword': { + 'child': { + 'name': 'Luis Lawson' + }, + 'event': { + 'name': 'Dog hospital number.' + }, + 'password': 'the correct password' } } } -snapshots["test_child_enrol_occurence_from_different_project 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Derek Perry"}, - "createdAt": "2020-12-12T00:00:00+00:00", - "occurrence": {"time": "2020-12-12T00:00:00+00:00"}, +snapshots['test_child_enrol_occurence_from_different_project 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Derek Perry' + }, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'occurrence': { + 'time': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_delete_event_group[model_perm] 1"] = { - "data": {"deleteEventGroup": {"__typename": "DeleteEventGroupMutationPayload"}} +snapshots['test_delete_event_group[model_perm] 1'] = { + 'data': { + 'deleteEventGroup': { + '__typename': 'DeleteEventGroupMutationPayload' + } + } } -snapshots["test_delete_event_group[object_perm] 1"] = { - "data": {"deleteEventGroup": {"__typename": "DeleteEventGroupMutationPayload"}} +snapshots['test_delete_event_group[object_perm] 1'] = { + 'data': { + 'deleteEventGroup': { + '__typename': 'DeleteEventGroupMutationPayload' + } + } } -snapshots["test_enrol_limit_reached[False-0-False] 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Derek Perry"}, - "createdAt": "2020-11-11T00:00:00+00:00", - "occurrence": {"time": "2020-11-11T00:00:00+00:00"}, +snapshots['test_enrol_limit_reached[False-0-False] 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Derek Perry' + }, + 'createdAt': '2020-11-11T00:00:00+00:00', + 'occurrence': { + 'time': '2020-11-11T00:00:00+00:00' + } } } } } -snapshots["test_enrol_limit_reached[False-1-False] 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Derek Perry"}, - "createdAt": "2020-11-11T00:00:00+00:00", - "occurrence": {"time": "2020-11-11T00:00:00+00:00"}, +snapshots['test_enrol_limit_reached[False-1-False] 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Derek Perry' + }, + 'createdAt': '2020-11-11T00:00:00+00:00', + 'occurrence': { + 'time': '2020-11-11T00:00:00+00:00' + } } } } } -snapshots["test_enrol_limit_reached[True-0-False] 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Derek Perry"}, - "createdAt": "2020-11-11T00:00:00+00:00", - "occurrence": {"time": "2020-11-11T00:00:00+00:00"}, +snapshots['test_enrol_limit_reached[True-0-False] 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Derek Perry' + }, + 'createdAt': '2020-11-11T00:00:00+00:00', + 'occurrence': { + 'time': '2020-11-11T00:00:00+00:00' + } } } } } -snapshots["test_enrol_limit_reached[True-1-False] 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Derek Perry"}, - "createdAt": "2020-11-11T00:00:00+00:00", - "occurrence": {"time": "2020-11-11T00:00:00+00:00"}, +snapshots['test_enrol_limit_reached[True-1-False] 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Derek Perry' + }, + 'createdAt': '2020-11-11T00:00:00+00:00', + 'occurrence': { + 'time': '2020-11-11T00:00:00+00:00' + } } } } } -snapshots["test_enrol_occurrence 1"] = { - "data": { - "enrolOccurrence": { - "enrolment": { - "child": {"name": "Sandra Brown"}, - "createdAt": "2020-12-12T00:00:00+00:00", - "occurrence": {"time": "2020-12-12T00:00:00+00:00"}, +snapshots['test_enrol_occurrence 1'] = { + 'data': { + 'enrolOccurrence': { + 'enrolment': { + 'child': { + 'name': 'Sandra Brown' + }, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'occurrence': { + 'time': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_enrolment_visibility 1"] = { - "data": { - "occurrence": { - "enrolmentCount": 4, - "enrolments": {"edges": [{"node": {"child": {"name": "Sandra Brown"}}}]}, - "event": { - "capacityPerOccurrence": 25, - "duration": 1, - "image": "http://testserver/media/series.jpg", - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "publishedAt": "2020-12-12T00:00:00+00:00", - "translations": [ +snapshots['test_enrolment_visibility 1'] = { + 'data': { + 'occurrence': { + 'enrolmentCount': 4, + 'enrolments': { + 'edges': [ { - "description": "Law ago respond yard door indicate country. Direction traditional whether serious sister work. Beat pressure unit toward movie by.", - "languageCode": "FI", - "name": "Detail audience campaign college career fight data.", - "shortDescription": "Last in able local garden modern they.", + 'node': { + 'child': { + 'name': 'Sandra Brown' + } + } } - ], + ] }, - "occurrenceLanguage": "FI", - "remainingCapacity": 21, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T00:00:00+00:00", - "venue": { - "translations": [ + 'event': { + 'capacityPerOccurrence': 25, + 'duration': 1, + 'image': 'http://testserver/media/series.jpg', + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'translations': [ { - "accessibilityInfo": "Moment strong hand push book and interesting sit. Near increase process truth list pressure. Capital city sing himself yard stuff.", - "additionalInfo": """Sense person the probably. Simply state social believe policy. Score think turn argue present. -Prevent pressure point. Voice radio happen color scene.""", - "address": """404 Figueroa Trace -Pollardview, GA 81371""", - "arrivalInstructions": """Water those notice medical science sort. Front affect senior. Mission network who think significant land especially. -Staff read rule point leg within. Staff country actually generation five training.""", - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "languageCode": "FI", - "name": "Dog hospital number.", - "wwwUrl": "https://www.beck-sherman.com/", + 'description': 'Law ago respond yard door indicate country. Direction traditional whether serious sister work. Beat pressure unit toward movie by.', + 'languageCode': 'FI', + 'name': 'Detail audience campaign college career fight data.', + 'shortDescription': 'Last in able local garden modern they.' } ] }, + 'occurrenceLanguage': 'FI', + 'remainingCapacity': 21, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '2020-12-12T00:00:00+00:00', + 'venue': { + 'translations': [ + { + 'accessibilityInfo': 'Moment strong hand push book and interesting sit. Near increase process truth list pressure. Capital city sing himself yard stuff.', + 'additionalInfo': '''Sense person the probably. Simply state social believe policy. Score think turn argue present. +Prevent pressure point. Voice radio happen color scene.''', + 'address': '''404 Figueroa Trace +Pollardview, GA 81371''', + 'arrivalInstructions': '''Water those notice medical science sort. Front affect senior. Mission network who think significant land especially. +Staff read rule point leg within. Staff country actually generation five training.''', + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'languageCode': 'FI', + 'name': 'Dog hospital number.', + 'wwwUrl': 'https://www.beck-sherman.com/' + } + ] + } } } } -snapshots["test_enrolment_visibility_project_user 1"] = { - "data": { - "occurrence": { - "enrolments": {"edges": [{"node": {"child": {"name": "ME ME ME"}}}]} +snapshots['test_enrolment_visibility_project_user 1'] = { + 'data': { + 'occurrence': { + 'enrolments': { + 'edges': [ + { + 'node': { + 'child': { + 'name': 'ME ME ME' + } + } + } + ] + } } } } -snapshots["test_erroneous_ticket_verification 1"] = { - "data": {"verifyTicket": None}, - "errors": [ +snapshots['test_erroneous_ticket_verification 1'] = { + 'data': { + 'verifyTicket': None + }, + 'errors': [ { - "extensions": {"code": "GENERAL_ERROR"}, - "locations": [{"column": 5, "line": 3}], - "message": "Could not decode the enrolment id", - "path": ["verifyTicket"], + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 5, + 'line': 3 + } + ], + 'message': 'Could not decode the enrolment id', + 'path': [ + 'verifyTicket' + ] } - ], + ] } -snapshots["test_event_filter_by_project 1"] = { - "data": {"events": {"edges": [{"node": {"name": "Should be visible"}}]}} +snapshots['test_event_filter_by_project 1'] = { + 'data': { + 'events': { + 'edges': [ + { + 'node': { + 'name': 'Should be visible' + } + } + ] + } + } } -snapshots["test_event_group_events_filtering_by_available_for_child_id 1"] = { - "data": {"eventGroup": {"events": {"edges": [{"node": {"name": "ME ME ME"}}]}}} +snapshots['test_event_group_events_filtering_by_available_for_child_id 1'] = { + 'data': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'name': 'ME ME ME' + } + } + ] + } + } + } } -snapshots["test_event_group_events_filtering_by_available_for_child_id 2"] = { - "data": { - "eventGroup": { - "events": { - "edges": [ - {"node": {"name": "Election stay every something base."}}, - {"node": {"name": "ME ME ME"}}, +snapshots['test_event_group_events_filtering_by_available_for_child_id 2'] = { + 'data': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'name': 'Election stay every something base.' + } + }, + { + 'node': { + 'name': 'ME ME ME' + } + } ] } } } } -snapshots["test_event_group_query_normal_user_and_project_user[False] 1"] = { - "data": {"eventGroup": None} +snapshots['test_event_group_query_normal_user_and_project_user[False] 1'] = { + 'data': { + 'eventGroup': None + } } -snapshots["test_event_group_query_normal_user_and_project_user[False] 2"] = { - "data": { - "eventGroup": { - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "events": {"edges": []}, - "image": "thank.jpg", - "imageAltText": "", - "name": "Lead behind everyone agency start majority.", - "project": {"year": 2020}, - "publishedAt": None, - "shortDescription": "Answer entire increase thank certainly again thought.", - "translations": [ +snapshots['test_event_group_query_normal_user_and_project_user[False] 2'] = { + 'data': { + 'eventGroup': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'events': { + 'edges': [ + ] + }, + 'image': 'thank.jpg', + 'imageAltText': '', + 'name': 'Lead behind everyone agency start majority.', + 'project': { + 'year': 2020 + }, + 'publishedAt': None, + 'shortDescription': 'Answer entire increase thank certainly again thought.', + 'translations': [ { - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Lead behind everyone agency start majority.", - "shortDescription": "Answer entire increase thank certainly again thought.", + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Lead behind everyone agency start majority.', + 'shortDescription': 'Answer entire increase thank certainly again thought.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } } } -snapshots["test_event_group_query_normal_user_and_project_user[True] 1"] = { - "data": { - "eventGroup": { - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "events": {"edges": []}, - "image": "thank.jpg", - "imageAltText": "", - "name": "Lead behind everyone agency start majority.", - "project": {"year": 2020}, - "publishedAt": "2020-12-12T00:00:00+00:00", - "shortDescription": "Answer entire increase thank certainly again thought.", - "translations": [ +snapshots['test_event_group_query_normal_user_and_project_user[True] 1'] = { + 'data': { + 'eventGroup': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'events': { + 'edges': [ + ] + }, + 'image': 'thank.jpg', + 'imageAltText': '', + 'name': 'Lead behind everyone agency start majority.', + 'project': { + 'year': 2020 + }, + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'shortDescription': 'Answer entire increase thank certainly again thought.', + 'translations': [ { - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Lead behind everyone agency start majority.", - "shortDescription": "Answer entire increase thank certainly again thought.", + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Lead behind everyone agency start majority.', + 'shortDescription': 'Answer entire increase thank certainly again thought.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } } } -snapshots["test_event_group_query_normal_user_and_project_user[True] 2"] = { - "data": { - "eventGroup": { - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "events": {"edges": []}, - "image": "thank.jpg", - "imageAltText": "", - "name": "Lead behind everyone agency start majority.", - "project": {"year": 2020}, - "publishedAt": "2020-12-12T00:00:00+00:00", - "shortDescription": "Answer entire increase thank certainly again thought.", - "translations": [ +snapshots['test_event_group_query_normal_user_and_project_user[True] 2'] = { + 'data': { + 'eventGroup': { + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'events': { + 'edges': [ + ] + }, + 'image': 'thank.jpg', + 'imageAltText': '', + 'name': 'Lead behind everyone agency start majority.', + 'project': { + 'year': 2020 + }, + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'shortDescription': 'Answer entire increase thank certainly again thought.', + 'translations': [ { - "description": """Page box child care any concern. Defense level church use. -Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Lead behind everyone agency start majority.", - "shortDescription": "Answer entire increase thank certainly again thought.", + 'description': '''Page box child care any concern. Defense level church use. +Never news behind. Beat at success decade either enter everything. Newspaper force newspaper business himself exist.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Lead behind everyone agency start majority.', + 'shortDescription': 'Answer entire increase thank certainly again thought.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } } } -snapshots["test_event_group_query_wrong_project 1"] = {"data": {"eventGroup": None}} +snapshots['test_event_group_query_wrong_project 1'] = { + 'data': { + 'eventGroup': None + } +} -snapshots["test_event_query_normal_user 1"] = { - "data": { - "event": { - "capacityPerOccurrence": 35, - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "duration": 181, - "image": "http://testserver/media/teacher.jpg", - "imageAltText": "", - "name": "Poor lawyer treat free heart significant.", - "occurrences": { - "edges": [ +snapshots['test_event_query_normal_user 1'] = { + 'data': { + 'event': { + 'capacityPerOccurrence': 35, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'duration': 181, + 'image': 'http://testserver/media/teacher.jpg', + 'imageAltText': '', + 'name': 'Poor lawyer treat free heart significant.', + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "remainingCapacity": 35, - "ticketSystem": {"type": "INTERNAL"}, - "time": "1970-12-29T14:27:50.629900+00:00", - "venue": { - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'remainingCapacity': 35, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '1970-12-29T14:27:50.629900+00:00', + 'venue': { + 'translations': [ { - "description": "Later evening southern would according strong. Analysis season project executive entire.", - "languageCode": "FI", - "name": "Skill down subject town range north skin.", + 'description': 'Later evening southern would according strong. Analysis season project executive entire.', + 'languageCode': 'FI', + 'name': 'Skill down subject town range north skin.' } ] - }, + } } } ] }, - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "project": {"year": 2020}, - "publishedAt": "2020-12-12T00:00:00+00:00", - "shortDescription": "Together history perform.", - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'project': { + 'year': 2020 + }, + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'shortDescription': 'Together history perform.', + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "shortDescription": "Together history perform.", + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'shortDescription': 'Together history perform.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } } } -snapshots["test_event_ticket_system_password_counts 1"] = { - "data": { - "event": {"ticketSystem": {"freePasswordCount": 3, "usedPasswordCount": 2}} +snapshots['test_event_ticket_system_password_counts 1'] = { + 'data': { + 'event': { + 'ticketSystem': { + 'freePasswordCount': 3, + 'usedPasswordCount': 2 + } + } } } -snapshots["test_event_ticket_system_password_own_child_password_exists 1"] = { - "data": { - "event": { - "ticketSystem": { - "childPassword": "the correct password", - "type": "TICKETMASTER", +snapshots['test_event_ticket_system_password_own_child_password_exists 1'] = { + 'data': { + 'event': { + 'ticketSystem': { + 'childPassword': 'the correct password', + 'type': 'TICKETMASTER' } } } } -snapshots["test_events_and_event_groups_query_normal_user 1"] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventNode", "name": "Published Event"}}, +snapshots['test_events_and_event_groups_query_normal_user 1'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventGroupNode", - "name": "Published EventGroup", + 'node': { + '__typename': 'EventNode', + 'name': 'Published Event' } }, + { + 'node': { + '__typename': 'EventGroupNode', + 'name': 'Published EventGroup' + } + } ] } } } -snapshots[ - "test_events_and_event_groups_query_project_filtering First project in filter, permission to see both projects" -] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventNode", "name": "The project's Event"}}, +snapshots['test_events_and_event_groups_query_project_filtering First project in filter, permission to see both projects'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventGroupNode", - "name": "The project's EventGroup", + 'node': { + '__typename': 'EventNode', + 'name': "The project's Event" } }, + { + 'node': { + '__typename': 'EventGroupNode', + 'name': "The project's EventGroup" + } + } ] } } } -snapshots[ - "test_events_and_event_groups_query_project_filtering No filter, no permission to see another project" -] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventNode", "name": "The project's Event"}}, +snapshots['test_events_and_event_groups_query_project_filtering No filter, no permission to see another project'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventGroupNode", - "name": "The project's EventGroup", + 'node': { + '__typename': 'EventNode', + 'name': "The project's Event" } }, + { + 'node': { + '__typename': 'EventGroupNode', + 'name': "The project's EventGroup" + } + } ] } } } -snapshots[ - "test_events_and_event_groups_query_project_filtering No filter, permission to see both projects" -] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventNode", "name": "The project's Event"}}, +snapshots['test_events_and_event_groups_query_project_filtering No filter, permission to see both projects'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ { - "node": { - "__typename": "EventNode", - "name": "Another project's Event", + 'node': { + '__typename': 'EventNode', + 'name': "The project's Event" } }, { - "node": { - "__typename": "EventGroupNode", - "name": "The project's EventGroup", + 'node': { + '__typename': 'EventNode', + 'name': "Another project's Event" } }, { - "node": { - "__typename": "EventGroupNode", - "name": "Another project's EventGroup", + 'node': { + '__typename': 'EventGroupNode', + 'name': "The project's EventGroup" } }, + { + 'node': { + '__typename': 'EventGroupNode', + 'name': "Another project's EventGroup" + } + } ] } } } -snapshots["test_events_and_event_groups_query_project_user 1"] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventNode", "name": "I should be the first"}}, +snapshots['test_events_and_event_groups_query_project_user 1'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ + { + 'node': { + '__typename': 'EventNode', + 'name': 'I should be the first' + } + }, { - "node": { - "__typename": "EventGroupNode", - "name": "I should be the in the middle", + 'node': { + '__typename': 'EventGroupNode', + 'name': 'I should be the in the middle' } }, - {"node": {"__typename": "EventNode", "name": "I should be the last"}}, + { + 'node': { + '__typename': 'EventNode', + 'name': 'I should be the last' + } + } ] } } } -snapshots["test_events_and_event_groups_query_upcoming_filter[False] 1"] = { - "data": { - "eventsAndEventGroups": { - "edges": [{"node": {"__typename": "EventNode", "name": "In the future"}}] +snapshots['test_events_and_event_groups_query_upcoming_filter[False] 1'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ + { + 'node': { + '__typename': 'EventNode', + 'name': 'In the future' + } + } + ] } } } -snapshots["test_events_and_event_groups_query_upcoming_filter[True] 1"] = { - "data": { - "eventsAndEventGroups": { - "edges": [ - {"node": {"__typename": "EventGroupNode", "name": "In the future"}} +snapshots['test_events_and_event_groups_query_upcoming_filter[True] 1'] = { + 'data': { + 'eventsAndEventGroups': { + 'edges': [ + { + 'node': { + '__typename': 'EventGroupNode', + 'name': 'In the future' + } + } ] } } } -snapshots["test_events_query_normal_user 1"] = { - "data": { - "events": { - "edges": [ +snapshots['test_events_query_normal_user 1'] = { + 'data': { + 'events': { + 'edges': [ { - "node": { - "capacityPerOccurrence": 35, - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "duration": 181, - "image": "http://testserver/media/teacher.jpg", - "imageAltText": "", - "name": "Poor lawyer treat free heart significant.", - "occurrences": { - "edges": [ + 'node': { + 'capacityPerOccurrence': 35, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'duration': 181, + 'image': 'http://testserver/media/teacher.jpg', + 'imageAltText': '', + 'name': 'Poor lawyer treat free heart significant.', + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "remainingCapacity": 35, - "ticketSystem": {"type": "INTERNAL"}, - "time": "1970-12-29T14:27:50.629900+00:00", - "venue": { - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'remainingCapacity': 35, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '1970-12-29T14:27:50.629900+00:00', + 'venue': { + 'translations': [ { - "description": "Later evening southern would according strong. Analysis season project executive entire.", - "languageCode": "FI", - "name": "Skill down subject town range north skin.", + 'description': 'Later evening southern would according strong. Analysis season project executive entire.', + 'languageCode': 'FI', + 'name': 'Skill down subject town range north skin.' } ] - }, + } } } ] }, - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "project": {"year": 2020}, - "publishedAt": "2020-12-12T00:00:00+00:00", - "shortDescription": "Together history perform.", - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'project': { + 'year': 2020 + }, + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'shortDescription': 'Together history perform.', + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "shortDescription": "Together history perform.", + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'shortDescription': 'Together history perform.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } } ] @@ -624,495 +840,628 @@ } } -snapshots["test_events_query_project_user 1"] = { - "data": { - "events": { - "edges": [ +snapshots['test_events_query_project_user 1'] = { + 'data': { + 'events': { + 'edges': [ { - "node": { - "capacityPerOccurrence": 35, - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "duration": 181, - "image": "http://testserver/media/teacher.jpg", - "imageAltText": "", - "name": "Poor lawyer treat free heart significant.", - "occurrences": { - "edges": [ + 'node': { + 'capacityPerOccurrence': 35, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'duration': 181, + 'image': 'http://testserver/media/teacher.jpg', + 'imageAltText': '', + 'name': 'Poor lawyer treat free heart significant.', + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "remainingCapacity": 35, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2004-11-06T11:51:21.341823+00:00", - "venue": { - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'remainingCapacity': 35, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '2004-11-06T11:51:21.341823+00:00', + 'venue': { + 'translations': [ { - "description": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "languageCode": "FI", - "name": "Land especially can quite industry relationship very.", + 'description': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'languageCode': 'FI', + 'name': 'Land especially can quite industry relationship very.' } ] - }, + } } } ] }, - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "project": {"year": 2020}, - "publishedAt": "2020-12-12T00:00:00+00:00", - "shortDescription": "Together history perform.", - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'project': { + 'year': 2020 + }, + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'shortDescription': 'Together history perform.', + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "shortDescription": "Together history perform.", + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'shortDescription': 'Together history perform.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } }, { - "node": { - "capacityPerOccurrence": 49, - "createdAt": "2020-12-12T00:00:00+00:00", - "description": """Wonder everything pay parent theory go home. Book and interesting sit future dream party. Truth list pressure stage history. -If his their best. Election stay every something base.""", - "duration": 42, - "image": "http://testserver/media/us.jpg", - "imageAltText": "", - "name": "Skill down subject town range north skin.", - "occurrences": { - "edges": [ + 'node': { + 'capacityPerOccurrence': 49, + 'createdAt': '2020-12-12T00:00:00+00:00', + 'description': '''Wonder everything pay parent theory go home. Book and interesting sit future dream party. Truth list pressure stage history. +If his their best. Election stay every something base.''', + 'duration': 42, + 'image': 'http://testserver/media/us.jpg', + 'imageAltText': '', + 'name': 'Skill down subject town range north skin.', + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "remainingCapacity": 49, - "ticketSystem": {"type": "INTERNAL"}, - "time": "1975-04-24T16:02:40.246613+00:00", - "venue": { - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'remainingCapacity': 49, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '1975-04-24T16:02:40.246613+00:00', + 'venue': { + 'translations': [ { - "description": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "languageCode": "FI", - "name": "Land especially can quite industry relationship very.", + 'description': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'languageCode': 'FI', + 'name': 'Land especially can quite industry relationship very.' } ] - }, + } } } ] }, - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "project": {"year": 2020}, - "publishedAt": None, - "shortDescription": "Later evening southern would according strong.", - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'project': { + 'year': 2020 + }, + 'publishedAt': None, + 'shortDescription': 'Later evening southern would according strong.', + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": """Wonder everything pay parent theory go home. Book and interesting sit future dream party. Truth list pressure stage history. -If his their best. Election stay every something base.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Skill down subject town range north skin.", - "shortDescription": "Later evening southern would according strong.", + 'description': '''Wonder everything pay parent theory go home. Book and interesting sit future dream party. Truth list pressure stage history. +If his their best. Election stay every something base.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Skill down subject town range north skin.', + 'shortDescription': 'Later evening southern would according strong.' } ], - "updatedAt": "2020-12-12T00:00:00+00:00", + 'updatedAt': '2020-12-12T00:00:00+00:00' } - }, + } ] } } } -snapshots["test_import_ticket_system_passwords 1"] = { - "data": { - "importTicketSystemPasswords": { - "errors": None, - "event": {"name": "Poor lawyer treat free heart significant."}, - "passwords": ["123", "asd", "xyz321"], +snapshots['test_import_ticket_system_passwords 1'] = { + 'data': { + 'importTicketSystemPasswords': { + 'errors': None, + 'event': { + 'name': 'Poor lawyer treat free heart significant.' + }, + 'passwords': [ + '123', + 'asd', + 'xyz321' + ] } } } -snapshots["test_import_ticket_system_passwords_errors_with_integrity_errors 1"] = { - "data": { - "importTicketSystemPasswords": { - "errors": [ +snapshots['test_import_ticket_system_passwords_errors_with_integrity_errors 1'] = { + 'data': { + 'importTicketSystemPasswords': { + 'errors': [ { - "field": "passwords", - "message": "Could not import password", - "value": "123", + 'field': 'passwords', + 'message': 'Could not import password', + 'value': '123' }, { - "field": "passwords", - "message": "Could not import password", - "value": "asd", + 'field': 'passwords', + 'message': 'Could not import password', + 'value': 'asd' }, { - "field": "passwords", - "message": "Could not import password", - "value": "xyz321", - }, + 'field': 'passwords', + 'message': 'Could not import password', + 'value': 'xyz321' + } ], - "event": {"name": "Poor lawyer treat free heart significant."}, - "passwords": ["more", "passwords", "to", "test", "errors"], + 'event': { + 'name': 'Poor lawyer treat free heart significant.' + }, + 'passwords': [ + 'more', + 'passwords', + 'to', + 'test', + 'errors' + ] } } } -snapshots["test_occurrence_available_capacity_and_enrolment_count 1"] = { - "data": { - "occurrence": { - "enrolmentCount": 3, - "enrolments": {"edges": []}, - "event": { - "capacityPerOccurrence": 9, - "duration": 1, - "image": "http://testserver/media/law.jpg", - "participantsPerInvite": "FAMILY", - "publishedAt": "2020-12-12T00:00:00+00:00", - "translations": [ +snapshots['test_occurrence_available_capacity_and_enrolment_count 1'] = { + 'data': { + 'occurrence': { + 'enrolmentCount': 3, + 'enrolments': { + 'edges': [ + ] + }, + 'event': { + 'capacityPerOccurrence': 9, + 'duration': 1, + 'image': 'http://testserver/media/law.jpg', + 'participantsPerInvite': 'FAMILY', + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'translations': [ { - "description": "Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.", - "languageCode": "FI", - "name": "Always sport return student light a point.", - "shortDescription": "Who Mrs public east site chance.", + 'description': 'Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.', + 'languageCode': 'FI', + 'name': 'Always sport return student light a point.', + 'shortDescription': 'Who Mrs public east site chance.' } - ], + ] }, - "occurrenceLanguage": "FI", - "remainingCapacity": 6, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T00:00:00+00:00", - "venue": { - "translations": [ + 'occurrenceLanguage': 'FI', + 'remainingCapacity': 6, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '2020-12-12T00:00:00+00:00', + 'venue': { + 'translations': [ { - "accessibilityInfo": """Like lay still bar. From daughter order stay sign discover eight. -Scientist service wonder everything pay. Moment strong hand push book and interesting sit.""", - "additionalInfo": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "address": """04883 Mary Corner -Port Mikeview, NY 31053""", - "arrivalInstructions": "Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.", - "description": """Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. -Page box child care any concern. Defense level church use.""", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "wwwUrl": "http://www.brooks.com/", + 'accessibilityInfo': '''Like lay still bar. From daughter order stay sign discover eight. +Scientist service wonder everything pay. Moment strong hand push book and interesting sit.''', + 'additionalInfo': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'address': '''04883 Mary Corner +Port Mikeview, NY 31053''', + 'arrivalInstructions': 'Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.', + 'description': '''Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. +Page box child care any concern. Defense level church use.''', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'wwwUrl': 'http://www.brooks.com/' } ] - }, + } } } } -snapshots["test_occurrence_capacity[0-0] 1"] = { - "data": { - "occurrence": { - "capacity": 0, - "capacityOverride": 0, - "enrolmentCount": 0, - "remainingCapacity": 0, +snapshots['test_occurrence_capacity[0-0] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 0, + 'capacityOverride': 0, + 'enrolmentCount': 0, + 'remainingCapacity': 0 } } } -snapshots["test_occurrence_capacity[5-0] 1"] = { - "data": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "remainingCapacity": 5, +snapshots['test_occurrence_capacity[5-0] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'remainingCapacity': 5 } } } -snapshots["test_occurrence_capacity[5-4] 1"] = { - "data": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 4, - "remainingCapacity": 1, +snapshots['test_occurrence_capacity[5-4] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 4, + 'remainingCapacity': 1 } } } -snapshots["test_occurrence_capacity[5-5] 1"] = { - "data": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 5, - "remainingCapacity": 0, +snapshots['test_occurrence_capacity[5-5] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 5, + 'remainingCapacity': 0 } } } -snapshots["test_occurrence_capacity[5-6] 1"] = { - "data": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 6, - "remainingCapacity": 0, +snapshots['test_occurrence_capacity[5-6] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 6, + 'remainingCapacity': 0 } } } -snapshots["test_occurrence_capacity[None-0] 1"] = { - "data": { - "occurrence": { - "capacity": 10, - "capacityOverride": None, - "enrolmentCount": 0, - "remainingCapacity": 10, +snapshots['test_occurrence_capacity[None-0] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 10, + 'capacityOverride': None, + 'enrolmentCount': 0, + 'remainingCapacity': 10 } } } -snapshots["test_occurrence_capacity[None-10] 1"] = { - "data": { - "occurrence": { - "capacity": 10, - "capacityOverride": None, - "enrolmentCount": 10, - "remainingCapacity": 0, +snapshots['test_occurrence_capacity[None-10] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 10, + 'capacityOverride': None, + 'enrolmentCount': 10, + 'remainingCapacity': 0 } } } -snapshots["test_occurrence_capacity[None-11] 1"] = { - "data": { - "occurrence": { - "capacity": 10, - "capacityOverride": None, - "enrolmentCount": 11, - "remainingCapacity": 0, +snapshots['test_occurrence_capacity[None-11] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 10, + 'capacityOverride': None, + 'enrolmentCount': 11, + 'remainingCapacity': 0 } } } -snapshots["test_occurrence_capacity[None-9] 1"] = { - "data": { - "occurrence": { - "capacity": 10, - "capacityOverride": None, - "enrolmentCount": 9, - "remainingCapacity": 1, +snapshots['test_occurrence_capacity[None-9] 1'] = { + 'data': { + 'occurrence': { + 'capacity': 10, + 'capacityOverride': None, + 'enrolmentCount': 9, + 'remainingCapacity': 1 } } } -snapshots["test_occurrence_query_normal_user 1"] = { - "data": { - "occurrence": { - "enrolmentCount": 0, - "enrolments": {"edges": []}, - "event": { - "capacityPerOccurrence": 9, - "duration": 1, - "image": "http://testserver/media/law.jpg", - "participantsPerInvite": "FAMILY", - "publishedAt": "2020-12-12T00:00:00+00:00", - "translations": [ +snapshots['test_occurrence_query_normal_user 1'] = { + 'data': { + 'occurrence': { + 'enrolmentCount': 0, + 'enrolments': { + 'edges': [ + ] + }, + 'event': { + 'capacityPerOccurrence': 9, + 'duration': 1, + 'image': 'http://testserver/media/law.jpg', + 'participantsPerInvite': 'FAMILY', + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'translations': [ { - "description": "Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.", - "languageCode": "FI", - "name": "Always sport return student light a point.", - "shortDescription": "Who Mrs public east site chance.", + 'description': 'Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.', + 'languageCode': 'FI', + 'name': 'Always sport return student light a point.', + 'shortDescription': 'Who Mrs public east site chance.' } - ], + ] + }, + 'occurrenceLanguage': 'FI', + 'remainingCapacity': 9, + 'ticketSystem': { + 'type': 'INTERNAL' }, - "occurrenceLanguage": "FI", - "remainingCapacity": 9, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T00:00:00+00:00", - "venue": { - "translations": [ + 'time': '2020-12-12T00:00:00+00:00', + 'venue': { + 'translations': [ { - "accessibilityInfo": """Like lay still bar. From daughter order stay sign discover eight. -Scientist service wonder everything pay. Moment strong hand push book and interesting sit.""", - "additionalInfo": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "address": """04883 Mary Corner -Port Mikeview, NY 31053""", - "arrivalInstructions": "Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.", - "description": """Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. -Page box child care any concern. Defense level church use.""", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "wwwUrl": "http://www.brooks.com/", + 'accessibilityInfo': '''Like lay still bar. From daughter order stay sign discover eight. +Scientist service wonder everything pay. Moment strong hand push book and interesting sit.''', + 'additionalInfo': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'address': '''04883 Mary Corner +Port Mikeview, NY 31053''', + 'arrivalInstructions': 'Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.', + 'description': '''Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. +Page box child care any concern. Defense level church use.''', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'wwwUrl': 'http://www.brooks.com/' } ] - }, + } } } } -snapshots["test_occurrence_ticket_system 1"] = { - "data": { - "occurrence": { - "ticketSystem": {"type": "TICKETMASTER", "url": "https://example.com"} +snapshots['test_occurrence_ticket_system 1'] = { + 'data': { + 'occurrence': { + 'ticketSystem': { + 'type': 'TICKETMASTER', + 'url': 'https://example.com' + } } } } -snapshots["test_occurrences_filter_by_date 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1970-01-02T00:00:00+00:00"}}, - {"node": {"time": "1970-01-02T00:00:00+00:00"}}, +snapshots['test_occurrences_filter_by_date 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1970-01-02T00:00:00+00:00' + } + }, + { + 'node': { + 'time': '1970-01-02T00:00:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_event 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1970-01-01T12:00:00+00:00"}}, - {"node": {"time": "1970-01-01T12:00:00+00:00"}}, +snapshots['test_occurrences_filter_by_event 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1970-01-01T12:00:00+00:00' + } + }, + { + 'node': { + 'time': '1970-01-01T12:00:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_language 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1988-06-02T19:08:36.943149+00:00"}}, - {"node": {"time": "1998-01-14T19:16:11.484399+00:00"}}, +snapshots['test_occurrences_filter_by_language 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1988-06-02T19:08:36.943149+00:00' + } + }, + { + 'node': { + 'time': '1998-01-14T19:16:11.484399+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_project 1"] = { - "data": { - "occurrences": {"edges": [{"node": {"time": "1970-01-01T12:00:00+00:00"}}]} +snapshots['test_occurrences_filter_by_project 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1970-01-01T12:00:00+00:00' + } + } + ] + } } } -snapshots["test_occurrences_filter_by_time 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1970-01-01T11:00:00+00:00"}}, - {"node": {"time": "1970-01-02T11:00:00+00:00"}}, +snapshots['test_occurrences_filter_by_time 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1970-01-01T11:00:00+00:00' + } + }, + { + 'node': { + 'time': '1970-01-02T11:00:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_upcoming 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1970-01-01T00:00:00+00:00"}}, - {"node": {"time": "2020-12-12T00:00:00+00:00"}}, +snapshots['test_occurrences_filter_by_upcoming 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1970-01-01T00:00:00+00:00' + } + }, + { + 'node': { + 'time': '2020-12-12T00:00:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_upcoming_with_leeway[False] 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "2020-12-11T23:29:00+00:00"}}, - {"node": {"time": "2020-12-11T23:31:00+00:00"}}, +snapshots['test_occurrences_filter_by_upcoming_with_leeway[False] 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2020-12-11T23:29:00+00:00' + } + }, + { + 'node': { + 'time': '2020-12-11T23:31:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_upcoming_with_leeway[True] 1"] = { - "data": { - "occurrences": {"edges": [{"node": {"time": "2020-12-11T23:31:00+00:00"}}]} +snapshots['test_occurrences_filter_by_upcoming_with_leeway[True] 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2020-12-11T23:31:00+00:00' + } + } + ] + } } } -snapshots["test_occurrences_filter_by_upcoming_with_ongoing[False] 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "2020-12-11T22:29:00+00:00"}}, - {"node": {"time": "2020-12-11T22:31:00+00:00"}}, +snapshots['test_occurrences_filter_by_upcoming_with_ongoing[False] 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2020-12-11T22:29:00+00:00' + } + }, + { + 'node': { + 'time': '2020-12-11T22:31:00+00:00' + } + } ] } } } -snapshots["test_occurrences_filter_by_upcoming_with_ongoing[True] 1"] = { - "data": { - "occurrences": {"edges": [{"node": {"time": "2020-12-11T22:31:00+00:00"}}]} +snapshots['test_occurrences_filter_by_upcoming_with_ongoing[True] 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2020-12-11T22:31:00+00:00' + } + } + ] + } } } -snapshots["test_occurrences_filter_by_venue 1"] = { - "data": { - "occurrences": { - "edges": [ - {"node": {"time": "1971-09-03T06:53:22.223652+00:00"}}, - {"node": {"time": "1981-10-20T21:01:52.047649+00:00"}}, - {"node": {"time": "2017-01-24T18:52:46.127687+00:00"}}, +snapshots['test_occurrences_filter_by_venue 1'] = { + 'data': { + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1971-09-03T06:53:22.223652+00:00' + } + }, + { + 'node': { + 'time': '1981-10-20T21:01:52.047649+00:00' + } + }, + { + 'node': { + 'time': '2017-01-24T18:52:46.127687+00:00' + } + } ] } } } -snapshots["test_occurrences_query_normal_user 1"] = { - "data": { - "occurrences": { - "edges": [ +snapshots['test_occurrences_query_normal_user 1'] = { + 'data': { + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "event": { - "capacityPerOccurrence": 9, - "duration": 1, - "image": "http://testserver/media/law.jpg", - "participantsPerInvite": "FAMILY", - "publishedAt": "2020-12-12T00:00:00+00:00", - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'event': { + 'capacityPerOccurrence': 9, + 'duration': 1, + 'image': 'http://testserver/media/law.jpg', + 'participantsPerInvite': 'FAMILY', + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'translations': [ { - "description": "Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.", - "languageCode": "FI", - "name": "Always sport return student light a point.", - "shortDescription": "Who Mrs public east site chance.", + 'description': 'Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.', + 'languageCode': 'FI', + 'name': 'Always sport return student light a point.', + 'shortDescription': 'Who Mrs public east site chance.' } - ], + ] + }, + 'remainingCapacity': 9, + 'ticketSystem': { + 'type': 'INTERNAL' }, - "remainingCapacity": 9, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T00:00:00+00:00", - "venue": { - "translations": [ + 'time': '2020-12-12T00:00:00+00:00', + 'venue': { + 'translations': [ { - "accessibilityInfo": """Like lay still bar. From daughter order stay sign discover eight. -Scientist service wonder everything pay. Moment strong hand push book and interesting sit.""", - "additionalInfo": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "address": """04883 Mary Corner -Port Mikeview, NY 31053""", - "arrivalInstructions": "Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.", - "description": """Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. -Page box child care any concern. Defense level church use.""", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "wwwUrl": "http://www.brooks.com/", + 'accessibilityInfo': '''Like lay still bar. From daughter order stay sign discover eight. +Scientist service wonder everything pay. Moment strong hand push book and interesting sit.''', + 'additionalInfo': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'address': '''04883 Mary Corner +Port Mikeview, NY 31053''', + 'arrivalInstructions': 'Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.', + 'description': '''Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. +Page box child care any concern. Defense level church use.''', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'wwwUrl': 'http://www.brooks.com/' } ] - }, + } } } ] @@ -1120,444 +1469,561 @@ } } -snapshots["test_occurrences_query_project_user 1"] = { - "data": { - "occurrences": { - "edges": [ +snapshots['test_occurrences_query_project_user 1'] = { + 'data': { + 'occurrences': { + 'edges': [ { - "node": { - "enrolmentCount": 0, - "event": { - "capacityPerOccurrence": 9, - "duration": 1, - "image": "http://testserver/media/law.jpg", - "participantsPerInvite": "FAMILY", - "publishedAt": "2020-12-12T00:00:00+00:00", - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'event': { + 'capacityPerOccurrence': 9, + 'duration': 1, + 'image': 'http://testserver/media/law.jpg', + 'participantsPerInvite': 'FAMILY', + 'publishedAt': '2020-12-12T00:00:00+00:00', + 'translations': [ { - "description": "Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.", - "languageCode": "FI", - "name": "Always sport return student light a point.", - "shortDescription": "Who Mrs public east site chance.", + 'description': 'Able last in able local. Quite nearly gun two born land. Yeah trouble method yard campaign former model.', + 'languageCode': 'FI', + 'name': 'Always sport return student light a point.', + 'shortDescription': 'Who Mrs public east site chance.' } - ], + ] }, - "remainingCapacity": 9, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T00:00:00+00:00", - "venue": { - "translations": [ + 'remainingCapacity': 9, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '2020-12-12T00:00:00+00:00', + 'venue': { + 'translations': [ { - "accessibilityInfo": """Like lay still bar. From daughter order stay sign discover eight. -Scientist service wonder everything pay. Moment strong hand push book and interesting sit.""", - "additionalInfo": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "address": """04883 Mary Corner -Port Mikeview, NY 31053""", - "arrivalInstructions": "Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.", - "description": """Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. -Page box child care any concern. Defense level church use.""", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "wwwUrl": "http://www.brooks.com/", + 'accessibilityInfo': '''Like lay still bar. From daughter order stay sign discover eight. +Scientist service wonder everything pay. Moment strong hand push book and interesting sit.''', + 'additionalInfo': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'address': '''04883 Mary Corner +Port Mikeview, NY 31053''', + 'arrivalInstructions': 'Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.', + 'description': '''Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. +Page box child care any concern. Defense level church use.''', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'wwwUrl': 'http://www.brooks.com/' } ] - }, + } } }, { - "node": { - "enrolmentCount": 0, - "event": { - "capacityPerOccurrence": 47, - "duration": 245, - "image": "http://testserver/media/answer.jpg", - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "publishedAt": None, - "translations": [ + 'node': { + 'enrolmentCount': 0, + 'event': { + 'capacityPerOccurrence': 47, + 'duration': 245, + 'image': 'http://testserver/media/answer.jpg', + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'publishedAt': None, + 'translations': [ { - "description": """Indeed discuss challenge school rule wish. Along hear follow sometimes. -Far magazine on summer.""", - "languageCode": "FI", - "name": "Notice rule huge realize at rather.", - "shortDescription": "Once strong artist save decide listen.", + 'description': '''Indeed discuss challenge school rule wish. Along hear follow sometimes. +Far magazine on summer.''', + 'languageCode': 'FI', + 'name': 'Notice rule huge realize at rather.', + 'shortDescription': 'Once strong artist save decide listen.' } - ], + ] + }, + 'remainingCapacity': 47, + 'ticketSystem': { + 'type': 'INTERNAL' }, - "remainingCapacity": 47, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2020-12-12T06:00:00+00:00", - "venue": { - "translations": [ + 'time': '2020-12-12T06:00:00+00:00', + 'venue': { + 'translations': [ { - "accessibilityInfo": """Like lay still bar. From daughter order stay sign discover eight. -Scientist service wonder everything pay. Moment strong hand push book and interesting sit.""", - "additionalInfo": "Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.", - "address": """04883 Mary Corner -Port Mikeview, NY 31053""", - "arrivalInstructions": "Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.", - "description": """Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. -Page box child care any concern. Defense level church use.""", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "wwwUrl": "http://www.brooks.com/", + 'accessibilityInfo': '''Like lay still bar. From daughter order stay sign discover eight. +Scientist service wonder everything pay. Moment strong hand push book and interesting sit.''', + 'additionalInfo': 'Training thought price. Effort clear and local challenge box. Care figure mention wrong when lead involve.', + 'address': '''04883 Mary Corner +Port Mikeview, NY 31053''', + 'arrivalInstructions': 'Benefit treat final central. Past ready join enjoy. Huge get this success commercial recently from.', + 'description': '''Together history perform. Respond draw military dog hospital number. Certainly again thought summer because serious listen. +Page box child care any concern. Defense level church use.''', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'wwwUrl': 'http://www.brooks.com/' } ] - }, + } } - }, + } ] } } } -snapshots["test_publish_event[model_perm] 1"] = { - "data": {"publishEvent": {"event": {"publishedAt": "2020-12-12T00:00:00+00:00"}}} +snapshots['test_publish_event[model_perm] 1'] = { + 'data': { + 'publishEvent': { + 'event': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + } } -snapshots["test_publish_event[object_perm] 1"] = { - "data": {"publishEvent": {"event": {"publishedAt": "2020-12-12T00:00:00+00:00"}}} +snapshots['test_publish_event[object_perm] 1'] = { + 'data': { + 'publishEvent': { + 'event': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + } } -snapshots["test_publish_event_group[model_perm] 1"] = { - "data": { - "publishEventGroup": { - "eventGroup": { - "events": { - "edges": [{"node": {"publishedAt": "2020-12-12T00:00:00+00:00"}}] +snapshots['test_publish_event_group[model_perm] 1'] = { + 'data': { + 'publishEventGroup': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + ] }, - "publishedAt": "2020-12-12T00:00:00+00:00", + 'publishedAt': '2020-12-12T00:00:00+00:00' } } } } -snapshots["test_publish_event_group[object_perm] 1"] = { - "data": { - "publishEventGroup": { - "eventGroup": { - "events": { - "edges": [{"node": {"publishedAt": "2020-12-12T00:00:00+00:00"}}] +snapshots['test_publish_event_group[object_perm] 1'] = { + 'data': { + 'publishEventGroup': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + ] }, - "publishedAt": "2020-12-12T00:00:00+00:00", + 'publishedAt': '2020-12-12T00:00:00+00:00' } } } } -snapshots["test_publish_ticketmaster_event[model_perm-False] 1"] = { - "data": {"publishEvent": {"event": {"publishedAt": "2020-12-12T00:00:00+00:00"}}} +snapshots['test_publish_ticketmaster_event[model_perm-False] 1'] = { + 'data': { + 'publishEvent': { + 'event': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + } } -snapshots["test_publish_ticketmaster_event[object_perm-False] 1"] = { - "data": {"publishEvent": {"event": {"publishedAt": "2020-12-12T00:00:00+00:00"}}} +snapshots['test_publish_ticketmaster_event[object_perm-False] 1'] = { + 'data': { + 'publishEvent': { + 'event': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } + } } -snapshots["test_republish_event_group[model_perm-True] 1"] = { - "data": { - "publishEventGroup": { - "eventGroup": { - "events": { - "edges": [ - {"node": {"publishedAt": "2020-12-11T00:00:00+00:00"}}, - {"node": {"publishedAt": "2020-12-12T00:00:00+00:00"}}, +snapshots['test_republish_event_group[model_perm-True] 1'] = { + 'data': { + 'publishEventGroup': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'publishedAt': '2020-12-11T00:00:00+00:00' + } + }, + { + 'node': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } ] }, - "publishedAt": "2020-12-12T00:00:00+00:00", + 'publishedAt': '2020-12-12T00:00:00+00:00' } } } } -snapshots["test_republish_event_group[object_perm-True] 1"] = { - "data": { - "publishEventGroup": { - "eventGroup": { - "events": { - "edges": [ - {"node": {"publishedAt": "2020-12-11T00:00:00+00:00"}}, - {"node": {"publishedAt": "2020-12-12T00:00:00+00:00"}}, +snapshots['test_republish_event_group[object_perm-True] 1'] = { + 'data': { + 'publishEventGroup': { + 'eventGroup': { + 'events': { + 'edges': [ + { + 'node': { + 'publishedAt': '2020-12-11T00:00:00+00:00' + } + }, + { + 'node': { + 'publishedAt': '2020-12-12T00:00:00+00:00' + } + } ] }, - "publishedAt": "2020-12-12T00:00:00+00:00", + 'publishedAt': '2020-12-12T00:00:00+00:00' } } } } -snapshots["test_required_translation 1"] = { - "data": { - "addEvent": { - "event": { - "capacityPerOccurrence": 30, - "duration": 1000, - "image": "", - "imageAltText": "Image alt text", - "participantsPerInvite": "FAMILY", - "project": {"year": 2020}, - "publishedAt": None, - "readyForEventGroupPublishing": False, - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ - { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event test", - "shortDescription": "Short desc", - } - ], - } +snapshots['test_required_translation 1'] = { + 'data': { + 'addEvent': { + 'event': None } - } + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 7, + 'line': 18 + } + ], + 'message': "Enum 'EventParticipantsPerInvite' cannot represent value: 'EnumMeta.FAMILY'", + 'path': [ + 'addEvent', + 'event', + 'participantsPerInvite' + ] + } + ] } -snapshots["test_set_enrolment_attendance[None] 1"] = { - "data": {"setEnrolmentAttendance": {"enrolment": {"attended": None}}} +snapshots['test_set_enrolment_attendance[None] 1'] = { + 'data': { + 'setEnrolmentAttendance': { + 'enrolment': { + 'attended': None + } + } + } } -snapshots["test_set_enrolment_attendance[True] 1"] = { - "data": {"setEnrolmentAttendance": {"enrolment": {"attended": True}}} +snapshots['test_set_enrolment_attendance[True] 1'] = { + 'data': { + 'setEnrolmentAttendance': { + 'enrolment': { + 'attended': True + } + } + } } -snapshots["test_unenrol_occurrence 1"] = { - "data": { - "unenrolOccurrence": { - "child": {"name": "David Perry"}, - "occurrence": {"time": "2020-12-12T00:00:00+00:00"}, +snapshots['test_unenrol_occurrence 1'] = { + 'data': { + 'unenrolOccurrence': { + 'child': { + 'name': 'David Perry' + }, + 'occurrence': { + 'time': '2020-12-12T00:00:00+00:00' + } } } } -snapshots["test_update_event_group[model_perm] 1"] = { - "data": { - "updateEventGroup": { - "eventGroup": { - "image": "teacher.jpg", - "translations": [ +snapshots['test_update_event_group[model_perm] 1'] = { + 'data': { + 'updateEventGroup': { + 'eventGroup': { + 'image': 'teacher.jpg', + 'translations': [ { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event group test in suomi", - "shortDescription": "Short desc", + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'FI', + 'name': 'Event group test in suomi', + 'shortDescription': 'Short desc' }, { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "SV", - "name": "Event group test in swedish", - "shortDescription": "Short desc", - }, - ], + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'SV', + 'name': 'Event group test in swedish', + 'shortDescription': 'Short desc' + } + ] } } } } -snapshots["test_update_event_group[object_perm] 1"] = { - "data": { - "updateEventGroup": { - "eventGroup": { - "image": "teacher.jpg", - "translations": [ +snapshots['test_update_event_group[object_perm] 1'] = { + 'data': { + 'updateEventGroup': { + 'eventGroup': { + 'image': 'teacher.jpg', + 'translations': [ { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event group test in suomi", - "shortDescription": "Short desc", + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'FI', + 'name': 'Event group test in suomi', + 'shortDescription': 'Short desc' }, { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "SV", - "name": "Event group test in swedish", - "shortDescription": "Short desc", - }, - ], + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'SV', + 'name': 'Event group test in swedish', + 'shortDescription': 'Short desc' + } + ] } } } } -snapshots["test_update_event_project_user 1"] = { - "data": { - "updateEvent": { - "event": { - "capacityPerOccurrence": 30, - "duration": 1000, - "image": "http://testserver/media/teacher.jpg", - "imageAltText": "Image alt text", - "occurrences": {"edges": []}, - "participantsPerInvite": "FAMILY", - "readyForEventGroupPublishing": True, - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ +snapshots['test_update_event_project_user 1'] = { + 'data': { + 'updateEvent': { + 'event': { + 'capacityPerOccurrence': 30, + 'duration': 1000, + 'image': 'http://testserver/media/teacher.jpg', + 'imageAltText': 'Image alt text', + 'occurrences': { + 'edges': [ + ] + }, + 'participantsPerInvite': 'FAMILY', + 'readyForEventGroupPublishing': True, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "FI", - "name": "Event test in suomi", - "shortDescription": "Short desc", + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'FI', + 'name': 'Event test in suomi', + 'shortDescription': 'Short desc' }, { - "description": "desc", - "imageAltText": "Image alt text", - "languageCode": "SV", - "name": "Event test in swedish", - "shortDescription": "Short desc", - }, - ], + 'description': 'desc', + 'imageAltText': 'Image alt text', + 'languageCode': 'SV', + 'name': 'Event test in swedish', + 'shortDescription': 'Short desc' + } + ] } } } } -snapshots["test_update_event_ready_for_event_group_publishing 1"] = { - "data": { - "updateEvent": { - "event": { - "capacityPerOccurrence": 35, - "duration": 181, - "image": "http://testserver/media/teacher.jpg", - "imageAltText": "", - "occurrences": {"edges": []}, - "participantsPerInvite": "CHILD_AND_1_OR_2_GUARDIANS", - "readyForEventGroupPublishing": True, - "ticketSystem": {"type": "INTERNAL"}, - "translations": [ +snapshots['test_update_event_ready_for_event_group_publishing 1'] = { + 'data': { + 'updateEvent': { + 'event': { + 'capacityPerOccurrence': 35, + 'duration': 181, + 'image': 'http://testserver/media/teacher.jpg', + 'imageAltText': '', + 'occurrences': { + 'edges': [ + ] + }, + 'participantsPerInvite': 'CHILD_AND_1_OR_2_GUARDIANS', + 'readyForEventGroupPublishing': True, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'translations': [ { - "description": """Least then top sing. Serious listen police shake. Page box child care any concern. -Agree room laugh prevent make. Our very television beat at success decade.""", - "imageAltText": "", - "languageCode": "FI", - "name": "Poor lawyer treat free heart significant.", - "shortDescription": "Together history perform.", + 'description': '''Least then top sing. Serious listen police shake. Page box child care any concern. +Agree room laugh prevent make. Our very television beat at success decade.''', + 'imageAltText': '', + 'languageCode': 'FI', + 'name': 'Poor lawyer treat free heart significant.', + 'shortDescription': 'Together history perform.' } - ], + ] } } } } -snapshots["test_update_occurrence_different_year[True] 1"] = { - "data": { - "updateOccurrence": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "SV", - "remainingCapacity": 5, - "ticketSystem": {"type": "INTERNAL"}, - "time": "2021-12-12T00:00:00+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, +snapshots['test_update_occurrence_different_year[True] 1'] = { + 'data': { + 'updateOccurrence': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'SV', + 'remainingCapacity': 5, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '2021-12-12T00:00:00+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_update_occurrence_project_user 1"] = { - "data": { - "updateOccurrence": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "SV", - "remainingCapacity": 5, - "ticketSystem": {"type": "INTERNAL"}, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, +snapshots['test_update_occurrence_project_user 1'] = { + 'data': { + 'updateOccurrence': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'SV', + 'remainingCapacity': 5, + 'ticketSystem': { + 'type': 'INTERNAL' + }, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_update_occurrence_ticket_system_url[False-False] 1"] = { - "data": { - "updateOccurrence": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "SV", - "remainingCapacity": 5, - "ticketSystem": { - "type": "TICKETMASTER", - "url": "https://updated.example.com", +snapshots['test_update_occurrence_ticket_system_url[False-False] 1'] = { + 'data': { + 'updateOccurrence': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'SV', + 'remainingCapacity': 5, + 'ticketSystem': { + 'type': 'TICKETMASTER', + 'url': 'https://updated.example.com' }, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_update_occurrence_ticket_system_url[False-True] 1"] = { - "data": { - "updateOccurrence": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "SV", - "remainingCapacity": 5, - "ticketSystem": {"type": "TICKETMASTER", "url": ""}, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, +snapshots['test_update_occurrence_ticket_system_url[False-True] 1'] = { + 'data': { + 'updateOccurrence': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'SV', + 'remainingCapacity': 5, + 'ticketSystem': { + 'type': 'TICKETMASTER', + 'url': '' + }, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_update_occurrence_ticket_system_url[True-False] 1"] = { - "data": { - "updateOccurrence": { - "occurrence": { - "capacity": 5, - "capacityOverride": 5, - "enrolmentCount": 0, - "event": {"createdAt": "2020-12-12T00:00:00+00:00"}, - "occurrenceLanguage": "SV", - "remainingCapacity": 5, - "ticketSystem": { - "type": "TICKETMASTER", - "url": "https://updated.example.com", +snapshots['test_update_occurrence_ticket_system_url[True-False] 1'] = { + 'data': { + 'updateOccurrence': { + 'occurrence': { + 'capacity': 5, + 'capacityOverride': 5, + 'enrolmentCount': 0, + 'event': { + 'createdAt': '2020-12-12T00:00:00+00:00' + }, + 'occurrenceLanguage': 'SV', + 'remainingCapacity': 5, + 'ticketSystem': { + 'type': 'TICKETMASTER', + 'url': 'https://updated.example.com' }, - "time": "1986-12-12T16:40:48+00:00", - "venue": {"createdAt": "2020-12-12T00:00:00+00:00"}, + 'time': '1986-12-12T16:40:48+00:00', + 'venue': { + 'createdAt': '2020-12-12T00:00:00+00:00' + } } } } } -snapshots["test_update_ticketmaster_event 1"] = { - "data": {"updateEvent": {"event": {"ticketSystem": {"type": "TICKETMASTER"}}}} +snapshots['test_update_ticketmaster_event 1'] = { + 'data': { + 'updateEvent': { + 'event': { + 'ticketSystem': { + 'type': 'TICKETMASTER' + } + } + } + } } -snapshots["test_verify_invalid_ticket 1"] = { - "data": { - "verifyTicket": { - "eventName": "Record card my. Sure sister return.", - "occurrenceTime": "2020-12-11T00:00:00+00:00", - "validity": False, - "venueName": "Remember stay public high concern glass person.", +snapshots['test_verify_invalid_ticket 1'] = { + 'data': { + 'verifyTicket': { + 'eventName': 'Record card my. Sure sister return.', + 'occurrenceTime': '2020-12-11T00:00:00+00:00', + 'validity': False, + 'venueName': 'Remember stay public high concern glass person.' } } } -snapshots["test_verify_valid_ticket 1"] = { - "data": { - "verifyTicket": { - "eventName": "Record card my. Sure sister return.", - "occurrenceTime": "2020-12-12T00:00:00+00:00", - "validity": True, - "venueName": "Remember stay public high concern glass person.", +snapshots['test_verify_valid_ticket 1'] = { + 'data': { + 'verifyTicket': { + 'eventName': 'Record card my. Sure sister return.', + 'occurrenceTime': '2020-12-12T00:00:00+00:00', + 'validity': True, + 'venueName': 'Remember stay public high concern glass person.' } } } diff --git a/kukkuu/settings.py b/kukkuu/settings.py index b4d0e9b8..6757a4d4 100644 --- a/kukkuu/settings.py +++ b/kukkuu/settings.py @@ -307,6 +307,7 @@ GRAPHENE = { "SCHEMA": "kukkuu.schema.schema", "MIDDLEWARE": ["kukkuu.graphene.JWTMiddleware"], + "DJANGO_CHOICE_FIELD_ENUM_CONVERT": True, } GRAPHQL_JWT = {"JWT_AUTH_HEADER_PREFIX": "Bearer"} diff --git a/messaging/schema.py b/messaging/schema.py index 0c59d023..cac65ab5 100644 --- a/messaging/schema.py +++ b/messaging/schema.py @@ -13,7 +13,6 @@ from common.utils import ( get_node_id_from_global_id, get_obj_if_user_can_administer, - map_enums_to_values_in_kwargs, project_user_required, update_object_with_translations, ) @@ -179,7 +178,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): send_directly = kwargs.pop("send_directly", False) data = deepcopy(kwargs) @@ -232,7 +230,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): data = deepcopy(kwargs) message = get_obj_if_user_can_administer(info, data.pop("id"), Message) @@ -312,7 +309,6 @@ class Input: @classmethod @project_user_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): message = get_obj_if_user_can_administer(info, kwargs["id"], Message) @@ -334,7 +330,6 @@ class Input: @classmethod @project_user_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): message = get_obj_if_user_can_administer(info, kwargs["id"], Message) if message.sent_at: diff --git a/messaging/tests/snapshots/snap_test_api.py b/messaging/tests/snapshots/snap_test_api.py index b7631a27..8ff130b6 100644 --- a/messaging/tests/snapshots/snap_test_api.py +++ b/messaging/tests/snapshots/snap_test_api.py @@ -4,121 +4,135 @@ from snapshottest import Snapshot + snapshots = Snapshot() -snapshots["test_add_message[None] 1"] = { - "data": { - "addMessage": { - "message": { - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "translations": [ - { - "bodyText": "Testiteksti", - "languageCode": "FI", - "subject": "Testiotsikko", - } - ], - } +snapshots['test_add_message[None] 1'] = { + 'data': { + 'addMessage': None + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': '''value too long for type character varying(16) +''', + 'path': [ + 'addMessage' + ] } - } + ] } -snapshots["test_add_message[event] 1"] = { - "data": { - "addMessage": { - "message": { - "event": {"name": "Poor lawyer treat free heart significant."}, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "translations": [ - { - "bodyText": "Testiteksti", - "languageCode": "FI", - "subject": "Testiotsikko", - } - ], - } +snapshots['test_add_message[event] 1'] = { + 'data': { + 'addMessage': None + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': '''value too long for type character varying(16) +''', + 'path': [ + 'addMessage' + ] } - } + ] } -snapshots["test_add_message[occurrences] 1"] = { - "data": { - "addMessage": { - "message": { - "event": {"name": "Poor lawyer treat free heart significant."}, - "occurrences": { - "edges": [ - {"node": {"time": "1970-12-29T14:27:50.629900+00:00"}}, - {"node": {"time": "1977-02-25T23:14:59.889967+00:00"}}, - {"node": {"time": "1997-09-11T01:32:17.610651+00:00"}}, - ] - }, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "translations": [ - { - "bodyText": "Testiteksti", - "languageCode": "FI", - "subject": "Testiotsikko", - } - ], - } +snapshots['test_add_message[occurrences] 1'] = { + 'data': { + 'addMessage': None + }, + 'errors': [ + { + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': '''value too long for type character varying(16) +''', + 'path': [ + 'addMessage' + ] } - } + ] } -snapshots["test_cannot_do_message_query_unauthorized_wrong_project 1"] = { - "data": {"message": None} +snapshots['test_cannot_do_message_query_unauthorized_wrong_project 1'] = { + 'data': { + 'message': None + } } -snapshots["test_delete_message 1"] = { - "data": {"deleteMessage": {"clientMutationId": None}} +snapshots['test_delete_message 1'] = { + 'data': { + 'deleteMessage': { + 'clientMutationId': None + } + } } -snapshots["test_message_query 1"] = { - "data": { - "message": { - "bodyText": "Ruumisteksti.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Otsikko", +snapshots['test_message_query 1'] = { + 'data': { + 'message': { + 'bodyText': 'Ruumisteksti.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Otsikko' } } } -snapshots["test_messages_query 1"] = { - "data": { - "messages": { - "edges": [ +snapshots['test_messages_query 1'] = { + 'data': { + 'messages': { + 'edges': [ { - "node": { - "bodyText": "Ruumisteksti.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Otsikko", + 'node': { + 'bodyText': 'Ruumisteksti.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Otsikko' } } ] @@ -126,98 +140,127 @@ } } -snapshots["test_messages_query_occurrences_filter 1"] = { - "data": { - "messages": { - "edges": [ +snapshots['test_messages_query_occurrences_filter 1'] = { + 'data': { + 'messages': { + 'edges': [ { - "node": { - "bodyText": "Free heart significant machine try. President compare room hotel town south among. Fall long respond draw military dog. Increase thank certainly again thought summer. Beyond than trial western.", - "event": None, - "occurrences": { - "edges": [ - {"node": {"time": "1980-08-23T04:46:09.363315+00:00"}} + 'node': { + 'bodyText': 'Free heart significant machine try. President compare room hotel town south among. Fall long respond draw military dog. Increase thank certainly again thought summer. Beyond than trial western.', + 'event': None, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1980-08-23T04:46:09.363315+00:00' + } + } ] }, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Him question stay.", + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Him question stay.' } }, { - "node": { - "bodyText": "Child care any. Minute defense level church. Alone our very television beat at success.", - "event": None, - "occurrences": { - "edges": [ - {"node": {"time": "1980-08-23T04:46:09.363315+00:00"}} + 'node': { + 'bodyText': 'Child care any. Minute defense level church. Alone our very television beat at success.', + 'event': None, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '1980-08-23T04:46:09.363315+00:00' + } + } ] }, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Business hot PM.", + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Business hot PM.' } }, { - "node": { - "bodyText": "Focus significant kind. Laugh smile behavior whom gas. Significant minute rest. Special far magazine.", - "event": None, - "occurrences": { - "edges": [ - {"node": {"time": "2003-01-02T18:10:46.571751+00:00"}} + 'node': { + 'bodyText': 'Focus significant kind. Laugh smile behavior whom gas. Significant minute rest. Special far magazine.', + 'event': None, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2003-01-02T18:10:46.571751+00:00' + } + } ] }, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Attention practice.", + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Attention practice.' } }, { - "node": { - "bodyText": "Conference carry factor front Mr amount conference thing. Positive cold start rest tonight including believe. Respond range bit college question. Stop treatment suggest. Sometimes growth check court.", - "event": None, - "occurrences": { - "edges": [ - {"node": {"time": "2003-01-02T18:10:46.571751+00:00"}} + 'node': { + 'bodyText': 'Conference carry factor front Mr amount conference thing. Positive cold start rest tonight including believe. Respond range bit college question. Stop treatment suggest. Sometimes growth check court.', + 'event': None, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2003-01-02T18:10:46.571751+00:00' + } + } ] }, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Past life thus.", + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Past life thus.' } - }, + } ] } } } -snapshots["test_messages_query_project_filter 1"] = { - "data": { - "messages": { - "edges": [ +snapshots['test_messages_query_project_filter 1'] = { + 'data': { + 'messages': { + 'edges': [ { - "node": { - "bodyText": "Ruumisteksti.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Otsikko", + 'node': { + 'bodyText': 'Ruumisteksti.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Otsikko' } } ] @@ -225,250 +268,320 @@ } } -snapshots["test_messages_query_protocol_filter[email] 1"] = { - "data": { - "messages": { - "edges": [ +snapshots['test_messages_query_protocol_filter[email] 1'] = { + 'data': { + 'messages': { + 'edges': [ { - "node": { - "bodyText": "Which president smile staff country actually generation. Age member whatever open effort clear. Difficult look can. Care figure mention wrong when lead involve. Event lay yes policy data control as receive.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Partner exist true.", + 'node': { + 'bodyText': 'Which president smile staff country actually generation. Age member whatever open effort clear. Difficult look can. Care figure mention wrong when lead involve. Event lay yes policy data control as receive.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Partner exist true.' } }, { - "node": { - "bodyText": "Girl middle same space speak. Person the probably deep center develop character situation. Score think turn argue present.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Decade every town.", + 'node': { + 'bodyText': 'Girl middle same space speak. Person the probably deep center develop character situation. Score think turn argue present.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Decade every town.' } }, { - "node": { - "bodyText": "Voice radio happen color scene. Create state rock only. Several behavior media career decide season mission TV. Work head table city central deep response. Through resource professional debate produce college able.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Walk fish teach.", + 'node': { + 'bodyText': 'Voice radio happen color scene. Create state rock only. Several behavior media career decide season mission TV. Work head table city central deep response. Through resource professional debate produce college able.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Walk fish teach.' } }, { - "node": { - "bodyText": "Sea something western research. Candidate century network bar hear quite wonder. Up always sport return. Light a point charge stand store. Generation able take food share.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Product issue along.", + 'node': { + 'bodyText': 'Sea something western research. Candidate century network bar hear quite wonder. Up always sport return. Light a point charge stand store. Generation able take food share.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Product issue along.' } }, { - "node": { - "bodyText": "Site chance of performance. Hand cause receive kitchen middle. Step able last in able local garden. Nearly gun two born land military first.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "EMAIL", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Discussion remain.", + 'node': { + 'bodyText': 'Site chance of performance. Hand cause receive kitchen middle. Step able last in able local garden. Nearly gun two born land military first.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'EMAIL', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Discussion remain.' } - }, + } ] } } } -snapshots["test_messages_query_protocol_filter[sms] 1"] = { - "data": { - "messages": { - "edges": [ +snapshots['test_messages_query_protocol_filter[sms] 1'] = { + 'data': { + 'messages': { + 'edges': [ { - "node": { - "bodyText": "Free heart significant machine try. President compare room hotel town south among. Fall long respond draw military dog. Increase thank certainly again thought summer. Beyond than trial western.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Him question stay.", + 'node': { + 'bodyText': 'Free heart significant machine try. President compare room hotel town south among. Fall long respond draw military dog. Increase thank certainly again thought summer. Beyond than trial western.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Him question stay.' } }, { - "node": { - "bodyText": "Child care any. Minute defense level church. Alone our very television beat at success.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Business hot PM.", + 'node': { + 'bodyText': 'Child care any. Minute defense level church. Alone our very television beat at success.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Business hot PM.' } }, { - "node": { - "bodyText": "Enter everything history remember stay public high. Exist shoulder write century. Never skill down subject town. According hard enough watch condition like lay.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Detail.", + 'node': { + 'bodyText': 'Enter everything history remember stay public high. Exist shoulder write century. Never skill down subject town. According hard enough watch condition like lay.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Detail.' } }, { - "node": { - "bodyText": "From daughter order stay sign discover eight. Toward scientist service wonder everything. Middle moment strong hand push book and interesting. Near increase process truth list pressure. Capital city sing himself yard stuff.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Their tell.", + 'node': { + 'bodyText': 'From daughter order stay sign discover eight. Toward scientist service wonder everything. Middle moment strong hand push book and interesting. Near increase process truth list pressure. Capital city sing himself yard stuff.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Their tell.' } }, { - "node": { - "bodyText": "Base may middle good father boy economy. Fly discussion huge get this success. Science sort already name. Senior number scene today friend maintain marriage.", - "event": None, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ALL", - "sentAt": None, - "subject": "Even perhaps that.", + 'node': { + 'bodyText': 'Base may middle good father boy economy. Fly discussion huge get this success. Science sort already name. Senior number scene today friend maintain marriage.', + 'event': None, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ALL', + 'sentAt': None, + 'subject': 'Even perhaps that.' } - }, + } ] } } } -snapshots["test_send_message 1"] = { - "data": { - "sendMessage": { - "message": { - "protocol": "EMAIL", - "recipientCount": 1, - "sentAt": "2020-12-12T00:00:00+00:00", - "subject": "Otsikko", +snapshots['test_send_message 1'] = { + 'data': { + 'sendMessage': { + 'message': { + 'protocol': 'EMAIL', + 'recipientCount': 1, + 'sentAt': '2020-12-12T00:00:00+00:00', + 'subject': 'Otsikko' } } } } -snapshots["test_send_sms_message_sent_with_default_language 1"] = { - "data": { - "sendMessage": { - "message": { - "protocol": "SMS", - "recipientCount": 1, - "sentAt": "2020-12-12T00:00:00+00:00", - "subject": "Otsikko", +snapshots['test_send_sms_message_sent_with_default_language 1'] = { + 'data': { + 'sendMessage': { + 'message': { + 'protocol': 'SMS', + 'recipientCount': 1, + 'sentAt': '2020-12-12T00:00:00+00:00', + 'subject': 'Otsikko' } } } } -snapshots["test_update_message[None] 1"] = { - "data": { - "updateMessage": { - "message": { - "event": {"name": "Poor lawyer treat free heart significant."}, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ATTENDED", - "sentAt": None, - "translations": [ +snapshots['test_update_message[None] 1'] = { + 'data': { + 'updateMessage': { + 'message': { + 'event': { + 'name': 'Poor lawyer treat free heart significant.' + }, + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ATTENDED', + 'sentAt': None, + 'translations': [ { - "bodyText": "Päivitetty testiteksti.", - "languageCode": "FI", - "subject": "Päivitetty testiotsikko", + 'bodyText': 'Päivitetty testiteksti.', + 'languageCode': 'FI', + 'subject': 'Päivitetty testiotsikko' } - ], + ] } } } } -snapshots["test_update_message[event] 1"] = { - "data": { - "updateMessage": { - "message": { - "event": { - "name": "Up property work indeed take. Popular care receive camera." +snapshots['test_update_message[event] 1'] = { + 'data': { + 'updateMessage': { + 'message': { + 'event': { + 'name': 'Up property work indeed take. Popular care receive camera.' }, - "occurrences": {"edges": []}, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ATTENDED", - "sentAt": None, - "translations": [ + 'occurrences': { + 'edges': [ + ] + }, + 'project': { + 'year': 2020 + }, + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ATTENDED', + 'sentAt': None, + 'translations': [ { - "bodyText": "Päivitetty testiteksti.", - "languageCode": "FI", - "subject": "Päivitetty testiotsikko", + 'bodyText': 'Päivitetty testiteksti.', + 'languageCode': 'FI', + 'subject': 'Päivitetty testiotsikko' } - ], + ] } } } } -snapshots["test_update_message[event_and_occurrences] 1"] = { - "data": { - "updateMessage": { - "message": { - "event": { - "name": "Up property work indeed take. Popular care receive camera." +snapshots['test_update_message[event_and_occurrences] 1'] = { + 'data': { + 'updateMessage': { + 'message': { + 'event': { + 'name': 'Up property work indeed take. Popular care receive camera.' + }, + 'occurrences': { + 'edges': [ + { + 'node': { + 'time': '2016-08-16T07:10:00+00:00' + } + } + ] }, - "occurrences": { - "edges": [{"node": {"time": "2016-08-16T07:10:00+00:00"}}] + 'project': { + 'year': 2020 }, - "project": {"year": 2020}, - "protocol": "SMS", - "recipientCount": 0, - "recipientSelection": "ATTENDED", - "sentAt": None, - "translations": [ + 'protocol': 'SMS', + 'recipientCount': 0, + 'recipientSelection': 'ATTENDED', + 'sentAt': None, + 'translations': [ { - "bodyText": "Päivitetty testiteksti.", - "languageCode": "FI", - "subject": "Päivitetty testiotsikko", + 'bodyText': 'Päivitetty testiteksti.', + 'languageCode': 'FI', + 'subject': 'Päivitetty testiotsikko' } - ], + ] } } } diff --git a/messaging/tests/test_api.py b/messaging/tests/test_api.py index 1551dbbd..34f86302 100644 --- a/messaging/tests/test_api.py +++ b/messaging/tests/test_api.py @@ -289,7 +289,7 @@ def test_add_message(snapshot, project_user_api_client, project, event_selection snapshot.assert_match(executed) -@pytest.mark.parametrize("protocol", ["EMAIL", "SMS"]) +@pytest.mark.parametrize("protocol", [Message.EMAIL, Message.SMS]) @patch.object(SMSNotificationService, "send_sms") def test_send_email_directly_with_add_message( mock_send_sms, protocol, project, project_user_api_client @@ -297,12 +297,12 @@ def test_send_email_directly_with_add_message( ChildWithGuardianFactory() variables = get_add_message_variables( - project, protocol=protocol, send_directly=True + project, protocol=protocol.upper(), send_directly=True ) project_user_api_client.execute(ADD_MESSAGE_MUTATION, variables=variables) - if protocol == "SMS": + if protocol == Message.SMS.upper(): mock_send_sms.assert_called_once() - elif protocol == "EMAIL": + elif protocol == Message.EMAIL.upper(): assert len(mail.outbox) == 1 @@ -421,7 +421,10 @@ def test_update_message(snapshot, project_user_api_client, event_selection): new_occurrences = [] variables = get_update_message_variables( - message, event=new_event, occurrences=new_occurrences, protocol="SMS" + message, + event=new_event, + occurrences=new_occurrences, + protocol=Message.SMS.upper(), ) executed = project_user_api_client.execute( diff --git a/subscriptions/schema.py b/subscriptions/schema.py index 0fc1604a..73c8f6ae 100644 --- a/subscriptions/schema.py +++ b/subscriptions/schema.py @@ -10,7 +10,6 @@ from common.utils import ( get_node_id_from_global_id, login_required, - map_enums_to_values_in_kwargs, ) from events.models import Occurrence from events.schema import OccurrenceNode @@ -107,7 +106,6 @@ class Input: @classmethod @login_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user child, occurrence = _get_child_and_occurrence(info, **kwargs) @@ -138,7 +136,6 @@ class Input: @classmethod @login_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user child, occurrence = _get_child_and_occurrence(info, **kwargs) @@ -193,7 +190,6 @@ class Input: use_only_when_first_denied=True, ) @login_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user user.unsubscribe_all_notification_subscriptions() diff --git a/users/schema.py b/users/schema.py index 9b7c1974..2427243a 100644 --- a/users/schema.py +++ b/users/schema.py @@ -6,7 +6,7 @@ from graphene_django.types import DjangoObjectType from common.schema import LanguageEnum, set_obj_languages_spoken_at_home -from common.utils import login_required, map_enums_to_values_in_kwargs, update_object +from common.utils import login_required, update_object from kukkuu.exceptions import ObjectDoesNotExistError from projects.schema import ProjectNode from verification_tokens.decorators import user_from_auth_verification_token @@ -97,7 +97,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user @@ -131,7 +130,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): user = info.context.user try: @@ -170,7 +168,6 @@ class Input: @classmethod @login_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): new_email = kwargs["email"] user = info.context.user @@ -212,7 +209,6 @@ class Input: use_only_when_first_denied=True, ) @login_required - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, has_accepted_communication, **kwargs): user = info.context.user try: diff --git a/users/tests/snapshots/snap_test_api.py b/users/tests/snapshots/snap_test_api.py index 523e0c76..4a3db706 100644 --- a/users/tests/snapshots/snap_test_api.py +++ b/users/tests/snapshots/snap_test_api.py @@ -4,32 +4,35 @@ from snapshottest import Snapshot + snapshots = Snapshot() -snapshots["test_guardians_query_normal_user 1"] = { - "data": { - "guardians": { - "edges": [ +snapshots['test_guardians_query_normal_user 1'] = { + 'data': { + 'guardians': { + 'edges': [ { - "node": { - "email": "michellewalker@example.net", - "firstName": "Andrew", - "lastName": "Eaton", - "phoneNumber": "001-311-571-5910x23202", - "relationships": { - "edges": [ + 'node': { + 'email': 'michellewalker@example.net', + 'firstName': 'Andrew', + 'lastName': 'Eaton', + 'phoneNumber': '001-311-571-5910x23202', + 'relationships': { + 'edges': [ { - "node": { - "child": { - "birthyear": 2023, - "name": "Nicholas Chavez", - "project": {"year": 2020}, + 'node': { + 'child': { + 'birthyear': 2023, + 'name': 'Nicholas Chavez', + 'project': { + 'year': 2020 + } }, - "type": "PARENT", + 'type': 'PARENT' } } ] - }, + } } } ] @@ -37,331 +40,373 @@ } } -snapshots["test_guardians_query_project_user 1"] = { - "data": { - "guardians": { - "edges": [ +snapshots['test_guardians_query_project_user 1'] = { + 'data': { + 'guardians': { + 'edges': [ { - "node": { - "email": "debbie77@example.com", - "firstName": "Guardian having children in own and another project", - "lastName": "Should be visible 1/2", - "phoneNumber": "(971)824-0675x0649", - "relationships": { - "edges": [ + 'node': { + 'email': 'debbie77@example.com', + 'firstName': 'Guardian having children in own and another project', + 'lastName': 'Should be visible 1/2', + 'phoneNumber': '(971)824-0675x0649', + 'relationships': { + 'edges': [ { - "node": { - "child": { - "birthyear": 2019, - "name": "Cynthia Holmes", - "project": {"year": 2020}, + 'node': { + 'child': { + 'birthyear': 2019, + 'name': 'Cynthia Holmes', + 'project': { + 'year': 2020 + } }, - "type": "PARENT", + 'type': 'PARENT' } } ] - }, + } } }, { - "node": { - "email": "michellewalker@example.net", - "firstName": "Another project own guardian", - "lastName": "Should be visible 2/2", - "phoneNumber": "420.928.1307", - "relationships": { - "edges": [ + 'node': { + 'email': 'michellewalker@example.net', + 'firstName': 'Another project own guardian', + 'lastName': 'Should be visible 2/2', + 'phoneNumber': '420.928.1307', + 'relationships': { + 'edges': [ { - "node": { - "child": { - "birthyear": 2022, - "name": "Sara Johnson", - "project": {"year": 2030}, + 'node': { + 'child': { + 'birthyear': 2022, + 'name': 'Sara Johnson', + 'project': { + 'year': 2030 + } }, - "type": "OTHER_RELATION", + 'type': 'OTHER_RELATION' } } ] - }, + } } - }, + } ] } } } -snapshots["test_my_admin_profile_project_admin[has_also_model_perm] 1"] = { - "data": { - "myAdminProfile": { - "projects": { - "edges": [ +snapshots['test_my_admin_profile_project_admin[has_also_model_perm] 1'] = { + 'data': { + 'myAdminProfile': { + 'projects': { + 'edges': [ { - "node": { - "myPermissions": { - "manageEventGroups": True, - "publish": True, + 'node': { + 'myPermissions': { + 'manageEventGroups': True, + 'publish': True }, - "name": "Helsingin kaupunginorkesteri", + 'name': 'Helsingin kaupunginorkesteri' } }, { - "node": { - "myPermissions": { - "manageEventGroups": True, - "publish": True, + 'node': { + 'myPermissions': { + 'manageEventGroups': True, + 'publish': True }, - "name": "project where base admin object perm but no other object perms", + 'name': 'project where base admin object perm but no other object perms' } }, { - "node": { - "myPermissions": { - "manageEventGroups": True, - "publish": True, + 'node': { + 'myPermissions': { + 'manageEventGroups': True, + 'publish': True }, - "name": "project where base admin object perm and other object perms", + 'name': 'project where base admin object perm and other object perms' } }, { - "node": { - "myPermissions": { - "manageEventGroups": True, - "publish": True, + 'node': { + 'myPermissions': { + 'manageEventGroups': True, + 'publish': True }, - "name": "project where no object perms", + 'name': 'project where no object perms' } - }, + } ] } } } } -snapshots["test_my_admin_profile_project_admin[no_model_perm] 1"] = { - "data": { - "myAdminProfile": { - "projects": { - "edges": [ +snapshots['test_my_admin_profile_project_admin[no_model_perm] 1'] = { + 'data': { + 'myAdminProfile': { + 'projects': { + 'edges': [ { - "node": { - "myPermissions": { - "manageEventGroups": False, - "publish": False, + 'node': { + 'myPermissions': { + 'manageEventGroups': False, + 'publish': False }, - "name": "project where base admin object perm but no other object perms", + 'name': 'project where base admin object perm but no other object perms' } }, { - "node": { - "myPermissions": { - "manageEventGroups": True, - "publish": True, + 'node': { + 'myPermissions': { + 'manageEventGroups': True, + 'publish': True }, - "name": "project where base admin object perm and other object perms", + 'name': 'project where base admin object perm and other object perms' } - }, + } ] } } } } -snapshots["test_my_communication_subscriptions_query_as_logged_in[False] 1"] = { - "data": { - "myCommunicationSubscriptions": { - "firstName": "Michael", - "hasAcceptedCommunication": False, - "language": "fi", - "lastName": "Patton", +snapshots['test_my_communication_subscriptions_query_as_logged_in[False] 1'] = { + 'data': { + 'myCommunicationSubscriptions': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': False, + 'language': 'fi', + 'lastName': 'Patton' } } } -snapshots["test_my_communication_subscriptions_query_as_logged_in[True] 1"] = { - "data": { - "myCommunicationSubscriptions": { - "firstName": "Michael", - "hasAcceptedCommunication": True, - "language": "fi", - "lastName": "Patton", +snapshots['test_my_communication_subscriptions_query_as_logged_in[True] 1'] = { + 'data': { + 'myCommunicationSubscriptions': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': True, + 'language': 'fi', + 'lastName': 'Patton' } } } -snapshots[ - "test_my_communication_subscriptions_query_with_auth_verification_token 1" -] = { - "data": { - "myCommunicationSubscriptions": { - "firstName": "Michael", - "hasAcceptedCommunication": True, - "language": "fi", - "lastName": "Patton", +snapshots['test_my_communication_subscriptions_query_with_auth_verification_token 1'] = { + 'data': { + 'myCommunicationSubscriptions': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': True, + 'language': 'fi', + 'lastName': 'Patton' } } } -snapshots["test_my_profile_no_profile 1"] = {"data": {"myProfile": None}} +snapshots['test_my_profile_no_profile 1'] = { + 'data': { + 'myProfile': None + } +} -snapshots["test_my_profile_query 1"] = { - "data": { - "myProfile": { - "email": "michellewalker@example.net", - "firstName": "Robert", - "hasAcceptedCommunication": False, - "language": "FI", - "languagesSpokenAtHome": {"edges": []}, - "lastName": "Crane", - "phoneNumber": "303.746.6972x70117", - "relationships": { - "edges": [ +snapshots['test_my_profile_query 1'] = { + 'data': { + 'myProfile': { + 'email': 'michellewalker@example.net', + 'firstName': 'Robert', + 'hasAcceptedCommunication': False, + 'language': 'FI', + 'languagesSpokenAtHome': { + 'edges': [ + ] + }, + 'lastName': 'Crane', + 'phoneNumber': '303.746.6972x70117', + 'relationships': { + 'edges': [ { - "node": { - "child": { - "birthyear": 2019, - "name": "Ashley Hernandez", - "postalCode": "28130", + 'node': { + 'child': { + 'birthyear': 2019, + 'name': 'Ashley Hernandez', + 'postalCode': '28130' }, - "type": "OTHER_GUARDIAN", + 'type': 'OTHER_GUARDIAN' } } ] - }, + } } } } -snapshots["test_my_profile_query_email[] 1"] = { - "data": {"myProfile": {"email": "user@example.com"}} +snapshots['test_my_profile_query_email[] 1'] = { + 'data': { + 'myProfile': { + 'email': 'user@example.com' + } + } } -snapshots["test_my_profile_query_email[guardian@example.com] 1"] = { - "data": {"myProfile": {"email": "guardian@example.com"}} +snapshots['test_my_profile_query_email[guardian@example.com] 1'] = { + 'data': { + 'myProfile': { + 'email': 'guardian@example.com' + } + } } -snapshots["test_request_email_change_token_mutation 1"] = { - "data": { - "requestEmailUpdateToken": { - "email": "new-email@kummilapset.fi", - "emailUpdateTokenRequested": True, +snapshots['test_request_email_change_token_mutation 1'] = { + 'data': { + 'requestEmailUpdateToken': { + 'email': 'new-email@kummilapset.fi', + 'emailUpdateTokenRequested': True } } } -snapshots["test_update_my_communication_subscriptions_as_logged_in[False] 1"] = { - "data": { - "updateMyCommunicationSubscriptions": { - "guardian": { - "firstName": "Michael", - "hasAcceptedCommunication": True, - "language": "fi", - "lastName": "Patton", +snapshots['test_update_my_communication_subscriptions_as_logged_in[False] 1'] = { + 'data': { + 'updateMyCommunicationSubscriptions': { + 'guardian': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': True, + 'language': 'fi', + 'lastName': 'Patton' } } } } -snapshots["test_update_my_communication_subscriptions_as_logged_in[True] 1"] = { - "data": { - "updateMyCommunicationSubscriptions": { - "guardian": { - "firstName": "Michael", - "hasAcceptedCommunication": False, - "language": "fi", - "lastName": "Patton", +snapshots['test_update_my_communication_subscriptions_as_logged_in[True] 1'] = { + 'data': { + 'updateMyCommunicationSubscriptions': { + 'guardian': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': False, + 'language': 'fi', + 'lastName': 'Patton' } } } } -snapshots[ - "test_update_my_communication_subscriptions_returns_errors_without_required_args[variables0] 1" -] = { - "data": None, - "errors": [ +snapshots['test_update_my_communication_subscriptions_returns_errors_without_required_args[variables0] 1'] = { + 'data': None, + 'errors': [ { - "extensions": {"code": "GENERAL_ERROR"}, - "locations": [{"column": 3, "line": 3}], - "message": "Variable '$input' got invalid value {}; Field 'hasAcceptedCommunication' of required type 'Boolean!' was not provided.", + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': "Variable '$input' got invalid value {}; Field 'hasAcceptedCommunication' of required type 'Boolean!' was not provided." } - ], + ] } -snapshots[ - "test_update_my_communication_subscriptions_returns_errors_without_required_args[variables1] 1" -] = { - "data": None, - "errors": [ +snapshots['test_update_my_communication_subscriptions_returns_errors_without_required_args[variables1] 1'] = { + 'data': None, + 'errors': [ { - "extensions": {"code": "GENERAL_ERROR"}, - "locations": [{"column": 3, "line": 3}], - "message": "Variable '$input' of required type 'UpdateMyCommunicationSubscriptionsMutationInput!' was not provided.", + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': "Variable '$input' of required type 'UpdateMyCommunicationSubscriptionsMutationInput!' was not provided." } - ], + ] } -snapshots[ - "test_update_my_communication_subscriptions_returns_errors_without_required_args[variables2] 1" -] = { - "data": None, - "errors": [ +snapshots['test_update_my_communication_subscriptions_returns_errors_without_required_args[variables2] 1'] = { + 'data': None, + 'errors': [ { - "extensions": {"code": "GENERAL_ERROR"}, - "locations": [{"column": 3, "line": 3}], - "message": "Variable '$input' got invalid value {'authToken': 'what ever'}; Field 'hasAcceptedCommunication' of required type 'Boolean!' was not provided.", + 'extensions': { + 'code': 'GENERAL_ERROR' + }, + 'locations': [ + { + 'column': 3, + 'line': 3 + } + ], + 'message': "Variable '$input' got invalid value {'authToken': 'what ever'}; Field 'hasAcceptedCommunication' of required type 'Boolean!' was not provided." } - ], + ] } -snapshots[ - "test_update_my_communication_subscriptions_with_auth_verification_token[False] 1" -] = { - "data": { - "updateMyCommunicationSubscriptions": { - "guardian": { - "firstName": "Michael", - "hasAcceptedCommunication": True, - "language": "fi", - "lastName": "Patton", +snapshots['test_update_my_communication_subscriptions_with_auth_verification_token[False] 1'] = { + 'data': { + 'updateMyCommunicationSubscriptions': { + 'guardian': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': True, + 'language': 'fi', + 'lastName': 'Patton' } } } } -snapshots[ - "test_update_my_communication_subscriptions_with_auth_verification_token[True] 1" -] = { - "data": { - "updateMyCommunicationSubscriptions": { - "guardian": { - "firstName": "Michael", - "hasAcceptedCommunication": False, - "language": "fi", - "lastName": "Patton", +snapshots['test_update_my_communication_subscriptions_with_auth_verification_token[True] 1'] = { + 'data': { + 'updateMyCommunicationSubscriptions': { + 'guardian': { + 'firstName': 'Michael', + 'hasAcceptedCommunication': False, + 'language': 'fi', + 'lastName': 'Patton' } } } } -snapshots["test_update_my_email_mutation[changed-email@kummilapset.fi-True] 1"] = { - "data": {"updateMyEmail": {"myProfile": {"email": "changed-email@kummilapset.fi"}}} +snapshots['test_update_my_email_mutation[changed-email@kummilapset.fi-True] 1'] = { + 'data': { + 'updateMyEmail': { + 'myProfile': { + 'email': 'changed-email@kummilapset.fi' + } + } + } } -snapshots["test_update_my_profile_mutation 1"] = { - "data": { - "updateMyProfile": { - "myProfile": { - "firstName": "Updated First Name", - "hasAcceptedCommunication": False, - "language": "EN", - "languagesSpokenAtHome": { - "edges": [ - {"node": {"alpha3Code": "swe"}}, - {"node": {"alpha3Code": "fin"}}, +snapshots['test_update_my_profile_mutation 1'] = { + 'data': { + 'updateMyProfile': { + 'myProfile': { + 'firstName': 'Updated First Name', + 'hasAcceptedCommunication': False, + 'language': 'EN', + 'languagesSpokenAtHome': { + 'edges': [ + { + 'node': { + 'alpha3Code': 'swe' + } + }, + { + 'node': { + 'alpha3Code': 'fin' + } + } ] }, - "lastName": "Updated Last Name", - "phoneNumber": "Updated phone number", + 'lastName': 'Updated Last Name', + 'phoneNumber': 'Updated phone number' } } } diff --git a/venues/schema.py b/venues/schema.py index 5d5d63fc..0dada0ee 100644 --- a/venues/schema.py +++ b/venues/schema.py @@ -12,7 +12,6 @@ from common.utils import ( get_obj_if_user_can_administer, login_required, - map_enums_to_values_in_kwargs, project_user_required, update_object_with_translations, ) @@ -111,7 +110,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): kwargs["project_id"] = get_obj_if_user_can_administer( info, kwargs["project_id"], Project @@ -136,7 +134,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): project_global_id = kwargs.pop("project_id", None) if project_global_id: @@ -160,7 +157,6 @@ class Input: @classmethod @project_user_required @transaction.atomic - @map_enums_to_values_in_kwargs def mutate_and_get_payload(cls, root, info, **kwargs): venue = get_obj_if_user_can_administer(info, kwargs["id"], Venue) log_text = f"user {info.context.user.uuid} deleted venue {venue}"