From 1c40b051077a3bf6e67fc1e841b6e557d8e20ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Wed, 21 Feb 2018 11:09:54 +0100
Subject: [PATCH] Add name collision id to Author and User types.

---
 openlobby/core/api/types.py                        | 4 ++++
 tests/schema/snapshots/snap_test_authors.py        | 8 ++++++++
 tests/schema/snapshots/snap_test_node.py           | 3 +++
 tests/schema/snapshots/snap_test_search_reports.py | 6 ++++++
 tests/schema/snapshots/snap_test_viewer.py         | 1 +
 tests/schema/test_authors.py                       | 6 ++++++
 tests/schema/test_node.py                          | 5 +++++
 tests/schema/test_search_reports.py                | 3 +++
 tests/schema/test_viewer.py                        | 1 +
 9 files changed, 37 insertions(+)

diff --git a/openlobby/core/api/types.py b/openlobby/core/api/types.py
index 2e6432d..50073c5 100644
--- a/openlobby/core/api/types.py
+++ b/openlobby/core/api/types.py
@@ -87,6 +87,7 @@ class User(graphene.ObjectType):
     openid_uid = graphene.String()
     first_name = graphene.String()
     last_name = graphene.String()
+    name_collision_id = graphene.Int()
     email = graphene.String()
     is_author = graphene.Boolean()
     extra = JSONString()
@@ -101,6 +102,7 @@ class User(graphene.ObjectType):
             openid_uid=user.openid_uid,
             first_name=user.first_name,
             last_name=user.last_name,
+            name_collision_id=user.name_collision_id,
             email=user.email,
             is_author=user.is_author,
             extra=user.extra,
@@ -118,6 +120,7 @@ class User(graphene.ObjectType):
 class Author(graphene.ObjectType):
     first_name = graphene.String()
     last_name = graphene.String()
+    name_collision_id = graphene.Int()
     total_reports = graphene.Int()
     extra = JSONString()
     reports = relay.ConnectionField(ReportConnection)
@@ -131,6 +134,7 @@ class Author(graphene.ObjectType):
             id=user.id,
             first_name=user.first_name,
             last_name=user.last_name,
+            name_collision_id=user.name_collision_id,
             extra=user.extra,
             total_reports=user.total_reports,
         )
diff --git a/tests/schema/snapshots/snap_test_authors.py b/tests/schema/snapshots/snap_test_authors.py
index 9f8b74d..c8dcecb 100644
--- a/tests/schema/snapshots/snap_test_authors.py
+++ b/tests/schema/snapshots/snap_test_authors.py
@@ -18,6 +18,7 @@ snapshots['test_all 1'] = {
                         'firstName': 'Shaun',
                         'id': 'QXV0aG9yOjM=',
                         'lastName': 'Sheep',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 },
@@ -28,6 +29,7 @@ snapshots['test_all 1'] = {
                         'firstName': 'Spongebob',
                         'id': 'QXV0aG9yOjI=',
                         'lastName': 'Squarepants',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 },
@@ -38,6 +40,7 @@ snapshots['test_all 1'] = {
                         'firstName': 'Winston',
                         'id': 'QXV0aG9yOjE=',
                         'lastName': 'Wolfe',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 }
@@ -64,6 +67,7 @@ snapshots['test_first 1'] = {
                         'firstName': 'Shaun',
                         'id': 'QXV0aG9yOjM=',
                         'lastName': 'Sheep',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 },
@@ -74,6 +78,7 @@ snapshots['test_first 1'] = {
                         'firstName': 'Spongebob',
                         'id': 'QXV0aG9yOjI=',
                         'lastName': 'Squarepants',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 }
@@ -100,6 +105,7 @@ snapshots['test_first_after 1'] = {
                         'firstName': 'Spongebob',
                         'id': 'QXV0aG9yOjI=',
                         'lastName': 'Squarepants',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 }
@@ -143,6 +149,7 @@ snapshots['test_last_before 1'] = {
                         'firstName': 'Spongebob',
                         'id': 'QXV0aG9yOjI=',
                         'lastName': 'Squarepants',
+                        'nameCollisionId': 0,
                         'totalReports': 0
                     }
                 }
@@ -168,6 +175,7 @@ snapshots['test_with_reports 1'] = {
                         'firstName': 'Winston',
                         'id': 'QXV0aG9yOjE=',
                         'lastName': 'Wolfe',
+                        'nameCollisionId': 0,
                         'reports': {
                             'edges': [
                                 {
diff --git a/tests/schema/snapshots/snap_test_node.py b/tests/schema/snapshots/snap_test_node.py
index dd7b1cf..b4cb9ab 100644
--- a/tests/schema/snapshots/snap_test_node.py
+++ b/tests/schema/snapshots/snap_test_node.py
@@ -23,6 +23,7 @@ snapshots['test_author 1'] = {
             'firstName': 'Winston',
             'id': 'QXV0aG9yOjU=',
             'lastName': 'Wolfe',
+            'nameCollisionId': 0,
             'totalReports': 0
         }
     }
@@ -42,6 +43,7 @@ snapshots['test_report 1'] = {
                 'firstName': 'Winston',
                 'id': 'QXV0aG9yOjE=',
                 'lastName': 'Wolfe',
+                'nameCollisionId': 0,
                 'totalReports': 1
             },
             'body': 'Long story short: we got the Ring!',
@@ -78,6 +80,7 @@ snapshots['test_user 1'] = {
             'id': 'VXNlcjo4',
             'isAuthor': False,
             'lastName': 'Einstein',
+            'nameCollisionId': 0,
             'openidUid': 'albert@einstein.id'
         }
     }
diff --git a/tests/schema/snapshots/snap_test_search_reports.py b/tests/schema/snapshots/snap_test_search_reports.py
index 3dd6bcc..ed5b20b 100644
--- a/tests/schema/snapshots/snap_test_search_reports.py
+++ b/tests/schema/snapshots/snap_test_search_reports.py
@@ -19,6 +19,7 @@ snapshots['test_all 1'] = {
                             'firstName': 'Spongebob',
                             'id': 'QXV0aG9yOjI=',
                             'lastName': 'Squarepants',
+                            'nameCollisionId': 0,
                             'totalReports': 1
                         },
                         'body': 'Another long story.',
@@ -41,6 +42,7 @@ snapshots['test_all 1'] = {
                             'firstName': 'Winston',
                             'id': 'QXV0aG9yOjE=',
                             'lastName': 'Wolfe',
+                            'nameCollisionId': 0,
                             'totalReports': 2
                         },
                         'body': 'Aragorn is the King. And we have lost the Ring.',
@@ -63,6 +65,7 @@ snapshots['test_all 1'] = {
                             'firstName': 'Winston',
                             'id': 'QXV0aG9yOjE=',
                             'lastName': 'Wolfe',
+                            'nameCollisionId': 0,
                             'totalReports': 2
                         },
                         'body': 'Long story short: we got the Ring!',
@@ -101,6 +104,7 @@ snapshots['test_query 1'] = {
                             'firstName': 'Spongebob',
                             'id': 'QXV0aG9yOjI=',
                             'lastName': 'Squarepants',
+                            'nameCollisionId': 0,
                             'totalReports': 1
                         },
                         'body': 'Another long story.',
@@ -133,6 +137,7 @@ snapshots['test_highlight 1'] = {
                             'firstName': 'Winston',
                             'id': 'QXV0aG9yOjE=',
                             'lastName': 'Wolfe',
+                            'nameCollisionId': 0,
                             'totalReports': 2
                         },
                         'body': 'Aragorn is the King. And we have lost the <mark>Ring</mark>.',
@@ -155,6 +160,7 @@ snapshots['test_highlight 1'] = {
                             'firstName': 'Winston',
                             'id': 'QXV0aG9yOjE=',
                             'lastName': 'Wolfe',
+                            'nameCollisionId': 0,
                             'totalReports': 2
                         },
                         'body': 'Long story short: we got the <mark>Ring</mark>!',
diff --git a/tests/schema/snapshots/snap_test_viewer.py b/tests/schema/snapshots/snap_test_viewer.py
index 947e074..9a897fb 100644
--- a/tests/schema/snapshots/snap_test_viewer.py
+++ b/tests/schema/snapshots/snap_test_viewer.py
@@ -22,6 +22,7 @@ snapshots['test_authenticated 1'] = {
             'id': 'VXNlcjox',
             'isAuthor': True,
             'lastName': 'Wolfe',
+            'nameCollisionId': 0,
             'openidUid': 'TheWolf'
         }
     }
diff --git a/tests/schema/test_authors.py b/tests/schema/test_authors.py
index b582d86..1547ec2 100644
--- a/tests/schema/test_authors.py
+++ b/tests/schema/test_authors.py
@@ -21,6 +21,7 @@ def test_all(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }
@@ -49,6 +50,7 @@ def test_first(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }
@@ -77,6 +79,7 @@ def test_first_after(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }
@@ -105,6 +108,7 @@ def test_last(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }
@@ -133,6 +137,7 @@ def test_last_before(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }
@@ -159,6 +164,7 @@ def test_with_reports(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                     reports {
diff --git a/tests/schema/test_node.py b/tests/schema/test_node.py
index 02b12aa..d475d4c 100644
--- a/tests/schema/test_node.py
+++ b/tests/schema/test_node.py
@@ -41,6 +41,7 @@ def test_author(client, snapshot):
                 id
                 firstName
                 lastName
+                nameCollisionId
                 totalReports
                 extra
             }}
@@ -84,6 +85,7 @@ def test_report(client, snapshot):
                     id
                     firstName
                     lastName
+                    nameCollisionId
                     totalReports
                     extra
                 }}
@@ -104,6 +106,7 @@ def test_user__unauthorized(client, snapshot):
                 id
                 firstName
                 lastName
+                nameCollisionId
                 openidUid
                 isAuthor
                 extra
@@ -127,6 +130,7 @@ def test_user__not_a_viewer(client, snapshot):
                 id
                 firstName
                 lastName
+                nameCollisionId
                 openidUid
                 isAuthor
                 extra
@@ -148,6 +152,7 @@ def test_user(client, snapshot):
                 id
                 firstName
                 lastName
+                nameCollisionId
                 openidUid
                 isAuthor
                 extra
diff --git a/tests/schema/test_search_reports.py b/tests/schema/test_search_reports.py
index 1309dda..2d2344a 100644
--- a/tests/schema/test_search_reports.py
+++ b/tests/schema/test_search_reports.py
@@ -29,6 +29,7 @@ def test_all(client, snapshot):
                         id
                         firstName
                         lastName
+                        nameCollisionId
                         totalReports
                         extra
                     }
@@ -69,6 +70,7 @@ def test_query(client, snapshot):
                         id
                         firstName
                         lastName
+                        nameCollisionId
                         totalReports
                         extra
                     }
@@ -103,6 +105,7 @@ def test_highlight(client, snapshot):
                         id
                         firstName
                         lastName
+                        nameCollisionId
                         totalReports
                         extra
                     }
diff --git a/tests/schema/test_viewer.py b/tests/schema/test_viewer.py
index 4ab66d2..bf22119 100644
--- a/tests/schema/test_viewer.py
+++ b/tests/schema/test_viewer.py
@@ -34,6 +34,7 @@ def test_authenticated(client, snapshot):
             id
             firstName
             lastName
+            nameCollisionId
             email
             openidUid
             isAuthor
-- 
GitLab