diff --git a/openlobby/core/api/mutations.py b/openlobby/core/api/mutations.py index 51bfb8563e0bc2fd969dc19ce651b97ab997a1b0..ec297e01a6353a5149e2851d293ca8577985db15 100644 --- a/openlobby/core/api/mutations.py +++ b/openlobby/core/api/mutations.py @@ -98,7 +98,7 @@ class Logout(relay.ClientIDMutation): return Logout(success=True) -class NewReport(relay.ClientIDMutation): +class CreateReport(relay.ClientIDMutation): class Input: title = graphene.String(required=True) @@ -129,7 +129,7 @@ class NewReport(relay.ClientIDMutation): other_participants=strip_all_tags(input.get('other_participants', '')), ) - return NewReport(report=types.Report.from_db(report)) + return CreateReport(report=types.Report.from_db(report)) class Mutation: @@ -137,4 +137,4 @@ class Mutation: login_by_shortcut = LoginByShortcut.Field() # TODO # logout = Logout.Field() - new_report = NewReport.Field() + create_report = CreateReport.Field() diff --git a/tests/mutations/snapshots/snap_test_new_report.py b/tests/mutations/snapshots/snap_test_create_report.py similarity index 95% rename from tests/mutations/snapshots/snap_test_new_report.py rename to tests/mutations/snapshots/snap_test_create_report.py index 1f223bbe8031ead1b9af28180b1e2cf44b584070..1ad80469591726bd2f26f510f7edc20f8c6c0e26 100644 --- a/tests/mutations/snapshots/snap_test_new_report.py +++ b/tests/mutations/snapshots/snap_test_create_report.py @@ -9,7 +9,7 @@ snapshots = Snapshot() snapshots['test_unauthorized 1'] = { 'data': { - 'newReport': None + 'createReport': None }, 'errors': [ { @@ -26,7 +26,7 @@ snapshots['test_unauthorized 1'] = { snapshots['test_full_report 1'] = { 'data': { - 'newReport': { + 'createReport': { 'report': { 'author': { 'extra': None, diff --git a/tests/mutations/test_new_report.py b/tests/mutations/test_create_report.py similarity index 83% rename from tests/mutations/test_new_report.py rename to tests/mutations/test_create_report.py index ac64910ce937f59dd67f35ad2ffe376ce65aa0d9..e1a32c837efdaa8008f7468527cc6f947c8b5548 100644 --- a/tests/mutations/test_new_report.py +++ b/tests/mutations/test_create_report.py @@ -30,8 +30,8 @@ def call_api(client, query, input, username=None): def test_unauthorized(client, snapshot): query = """ - mutation newReport ($input: NewReportInput!) { - newReport (input: $input) { + mutation createReport ($input: CreateReportInput!) { + createReport (input: $input) { report { id } @@ -51,8 +51,8 @@ def test_unauthorized(client, snapshot): def test_full_report(client, snapshot): query = """ - mutation newReport ($input: NewReportInput!) { - newReport (input: $input) { + mutation createReport ($input: CreateReportInput!) { + createReport (input: $input) { report { id date @@ -95,14 +95,12 @@ def test_full_report(client, snapshot): # published date is set on save, changing between test runs, so we strip it # from snapshot - published = response['data']['newReport']['report']['published'] - response['data']['newReport']['report']['published'] = '__STRIPPED__' - - # There is a strange issue with tests, that report get's ID 2 when all tests - # are run. Even when the there is just one Report in database. I tried to - # debug it, no luck to solve. So I just strip ID from snapshot and check it. - id = response['data']['newReport']['report']['id'] - response['data']['newReport']['report']['id'] = '__STRIPPED__' + published = response['data']['createReport']['report']['published'] + response['data']['createReport']['report']['published'] = '__STRIPPED__' + + # strip random ID from snapshot and check it + id = response['data']['createReport']['report']['id'] + response['data']['createReport']['report']['id'] = '__STRIPPED__' assert re.match(r'\w+', id) snapshot.assert_match(response) @@ -118,12 +116,13 @@ def test_full_report(client, snapshot): assert report.our_participants == our_participants assert report.other_participants == other_participants assert report.extra is None + assert report.is_draft is False def test_input_sanitization(client): query = """ - mutation newReport ($input: NewReportInput!) { - newReport (input: $input) { + mutation createReport ($input: CreateReportInput!) { + createReport (input: $input) { report { id }