From 2212aed1bbb50571ebaa088b3c03826ce02a3012 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Mon, 26 Feb 2018 00:18:40 +0100
Subject: [PATCH] Rename mutation NewReport to CreateReport.

---
 openlobby/core/api/mutations.py               |  6 ++---
 ...w_report.py => snap_test_create_report.py} |  4 +--
 ...st_new_report.py => test_create_report.py} | 27 +++++++++----------
 3 files changed, 18 insertions(+), 19 deletions(-)
 rename tests/mutations/snapshots/{snap_test_new_report.py => snap_test_create_report.py} (95%)
 rename tests/mutations/{test_new_report.py => test_create_report.py} (83%)

diff --git a/openlobby/core/api/mutations.py b/openlobby/core/api/mutations.py
index 51bfb85..ec297e0 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 1f223bb..1ad8046 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 ac64910..e1a32c8 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
             }
-- 
GitLab