Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openlobby Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
openlobby
Openlobby Server
Commits
50471b43
Commit
50471b43
authored
7 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
Schema tests refactoring.
parent
5dc9dfeb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
openlobby/core/tests/snapshots/snap_test_schema.py
+79
-6
79 additions, 6 deletions
openlobby/core/tests/snapshots/snap_test_schema.py
openlobby/core/tests/test_schema.py
+34
-30
34 additions, 30 deletions
openlobby/core/tests/test_schema.py
with
113 additions
and
36 deletions
openlobby/core/tests/snapshots/snap_test_schema.py
+
79
−
6
View file @
50471b43
...
@@ -7,14 +7,87 @@ from snapshottest import Snapshot
...
@@ -7,14 +7,87 @@ from snapshottest import Snapshot
snapshots
=
Snapshot
()
snapshots
=
Snapshot
()
snapshots
[
'
test_login_shortcuts__none 1
'
]
=
b
'
{
"
data
"
:{
"
loginShortcuts
"
:[]}}
'
snapshots
[
'
test_login_shortcuts__none 1
'
]
=
{
'
data
'
:
{
'
loginShortcuts
'
:
[
]
}
}
snapshots
[
'
test_login_shortcuts 1
'
]
=
b
'
{
"
data
"
:{
"
loginShortcuts
"
:[{
"
id
"
:
"
TG9naW5TaG9ydGN1dDoyMA==
"
,
"
name
"
:
"
bar
"
}]}}
'
snapshots
[
'
test_login_shortcuts 1
'
]
=
{
'
data
'
:
{
'
loginShortcuts
'
:
[
{
'
id
'
:
'
TG9naW5TaG9ydGN1dDoyMA==
'
,
'
name
'
:
'
bar
'
}
]
}
}
snapshots
[
'
test_node__login_shortcut 1
'
]
=
b
'
{
"
data
"
:{
"
node
"
:{
"
id
"
:
"
TG9naW5TaG9ydGN1dDoxMA==
"
,
"
name
"
:
"
foo
"
}}}
'
snapshots
[
'
test_node__login_shortcut 1
'
]
=
{
'
data
'
:
{
'
node
'
:
{
'
id
'
:
'
TG9naW5TaG9ydGN1dDoxMA==
'
,
'
name
'
:
'
foo
'
}
}
}
snapshots
[
'
test_node__author 1
'
]
=
b
'
{
"
data
"
:{
"
node
"
:{
"
id
"
:
"
QXV0aG9yOjU=
"
,
"
firstName
"
:
"
Winston
"
,
"
lastName
"
:
"
Wolfe
"
,
"
openidUid
"
:
"
TheWolf
"
,
"
extra
"
:
"
{
\\
"
x
\\
"
: 1}
"
}}}
'
snapshots
[
'
test_node__author 1
'
]
=
{
'
data
'
:
{
'
node
'
:
{
'
extra
'
:
'
{
"
x
"
: 1}
'
,
'
firstName
'
:
'
Winston
'
,
'
id
'
:
'
QXV0aG9yOjU=
'
,
'
lastName
'
:
'
Wolfe
'
,
'
openidUid
'
:
'
TheWolf
'
}
}
}
snapshots
[
'
test_node__author__only_if_is_author 1
'
]
=
b
'
{
"
data
"
:{
"
node
"
:null}}
'
snapshots
[
'
test_node__author__only_if_is_author 1
'
]
=
{
'
data
'
:
{
'
node
'
:
None
}
}
snapshots
[
'
test_authors 1
'
]
=
b
'
{
"
data
"
:{
"
authors
"
:{
"
totalCount
"
:1,
"
edges
"
:[{
"
node
"
:{
"
id
"
:
"
QXV0aG9yOjU=
"
,
"
firstName
"
:
"
Winston
"
,
"
lastName
"
:
"
Wolfe
"
,
"
openidUid
"
:
"
TheWolf
"
,
"
extra
"
:
"
{
\\
"
x
\\
"
: 1}
"
}}]}}}
'
snapshots
[
'
TestAuthors.test_all 1
'
]
=
{
'
data
'
:
{
'
authors
'
:
{
'
edges
'
:
[
{
'
cursor
'
:
'
MQ==
'
,
'
node
'
:
{
'
extra
'
:
'
{
"
x
"
: 1}
'
,
'
firstName
'
:
'
Winston
'
,
'
id
'
:
'
QXV0aG9yOjE=
'
,
'
lastName
'
:
'
Wolfe
'
,
'
openidUid
'
:
'
TheWolf
'
}
},
{
'
cursor
'
:
'
Mg==
'
,
'
node
'
:
{
'
extra
'
:
None
,
'
firstName
'
:
'
Captain
'
,
'
id
'
:
'
QXV0aG9yOjM=
'
,
'
lastName
'
:
'
Obvious
'
,
'
openidUid
'
:
'
ccc
'
}
},
{
'
cursor
'
:
'
Mw==
'
,
'
node
'
:
{
'
extra
'
:
None
,
'
firstName
'
:
'
Shaun
'
,
'
id
'
:
'
QXV0aG9yOjQ=
'
,
'
lastName
'
:
'
Sheep
'
,
'
openidUid
'
:
'
ddd
'
}
}
],
'
totalCount
'
:
3
}
}
}
This diff is collapsed.
Click to expand it.
openlobby/core/tests/test_schema.py
+
34
−
30
View file @
50471b43
...
@@ -16,7 +16,7 @@ def test_login_shortcuts(client, snapshot):
...
@@ -16,7 +16,7 @@ def test_login_shortcuts(client, snapshot):
}
}
}
}
"""
})
"""
})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
@pytest.mark.django_db
@pytest.mark.django_db
...
@@ -30,7 +30,7 @@ def test_login_shortcuts__none(client, snapshot):
...
@@ -30,7 +30,7 @@ def test_login_shortcuts__none(client, snapshot):
}
}
}
}
"""
})
"""
})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
@pytest.mark.django_db
@pytest.mark.django_db
...
@@ -46,7 +46,7 @@ def test_node__login_shortcut(client, snapshot):
...
@@ -46,7 +46,7 @@ def test_node__login_shortcut(client, snapshot):
}}
}}
}}
}}
"""
.
format
(
id
=
to_global_id
(
'
LoginShortcut
'
,
10
))})
"""
.
format
(
id
=
to_global_id
(
'
LoginShortcut
'
,
10
))})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
@pytest.mark.django_db
@pytest.mark.django_db
...
@@ -72,7 +72,7 @@ def test_node__author(client, snapshot):
...
@@ -72,7 +72,7 @@ def test_node__author(client, snapshot):
}}
}}
}}
}}
"""
.
format
(
id
=
to_global_id
(
'
Author
'
,
5
))})
"""
.
format
(
id
=
to_global_id
(
'
Author
'
,
5
))})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
@pytest.mark.django_db
@pytest.mark.django_db
...
@@ -87,26 +87,30 @@ def test_node__author__only_if_is_author(client, snapshot):
...
@@ -87,26 +87,30 @@ def test_node__author__only_if_is_author(client, snapshot):
}}
}}
}}
}}
"""
.
format
(
id
=
to_global_id
(
'
Author
'
,
7
))})
"""
.
format
(
id
=
to_global_id
(
'
Author
'
,
7
))})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
@pytest.mark.django_db
@pytest.mark.django_db
def
test_authors
(
client
,
snapshot
):
class
TestAuthors
:
User
.
objects
.
create
(
id
=
5
,
@pytest.fixture
(
autouse
=
True
)
username
=
'
a
'
,
def
setup
(
self
):
is_author
=
True
,
User
.
objects
.
create
(
id
=
1
,
is_author
=
True
,
username
=
'
a
'
,
openid_uid
=
'
TheWolf
'
,
openid_uid
=
'
TheWolf
'
,
first_name
=
'
Winston
'
,
last_name
=
'
Wolfe
'
,
extra
=
{
'
x
'
:
1
})
first_name
=
'
Winston
'
,
User
.
objects
.
create
(
id
=
2
,
is_author
=
False
,
username
=
'
b
'
)
last_name
=
'
Wolfe
'
,
User
.
objects
.
create
(
id
=
3
,
is_author
=
True
,
username
=
'
c
'
,
openid_uid
=
'
ccc
'
,
extra
=
{
'
x
'
:
1
},
first_name
=
'
Captain
'
,
last_name
=
'
Obvious
'
)
)
User
.
objects
.
create
(
id
=
4
,
is_author
=
True
,
username
=
'
d
'
,
openid_uid
=
'
ddd
'
,
User
.
objects
.
create
(
id
=
7
,
is_author
=
False
,
username
=
'
b
'
)
first_name
=
'
Shaun
'
,
last_name
=
'
Sheep
'
)
yield
def
test_all
(
self
,
client
,
snapshot
):
res
=
client
.
post
(
'
/graphql
'
,
{
'
query
'
:
"""
res
=
client
.
post
(
'
/graphql
'
,
{
'
query
'
:
"""
query {
query {
authors {
authors {
totalCount
totalCount
edges {
edges {
cursor
node {
node {
id
id
firstName
firstName
...
@@ -118,4 +122,4 @@ def test_authors(client, snapshot):
...
@@ -118,4 +122,4 @@ def test_authors(client, snapshot):
}
}
}
}
"""
})
"""
})
snapshot
.
assert_match
(
res
.
content
)
snapshot
.
assert_match
(
res
.
json
()
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment