-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathtests.py
148 lines (130 loc) · 3.98 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import mongoengine
from graphene.test import Client
from examples.falcon_mongoengine.schema import schema
from .fixtures import fixtures_data
mongoengine.connect("graphene-mongo-test", host="mongomock://localhost", alias="default")
def test_category_last_1_item_query(fixtures_data):
query = """
{
categories(last: 1){
edges {
node {
name
color
}
}
}
}"""
expected = {
"data": {
"categories": {
"edges": [
{
"node": {
"name": "Work",
"color": "#1769ff",
}
}
]
}
}
}
client = Client(schema)
result = client.execute(query)
assert result == expected
def test_category_filter_item_query(fixtures_data):
query = """
{
categories(name: "Work"){
edges {
node {
name
color
}
}
}
}"""
expected = {"data": {"categories": {"edges": [{"node": {"name": "Work", "color": "#1769ff"}}]}}}
client = Client(schema)
result = client.execute(query)
assert result == expected
def test_bookmarks_first_2_items_query(fixtures_data):
query = """
{
bookmarks(first: 2){
edges {
node {
name
url
category {
name
color
}
tags
}
}
}
}"""
expected = {
"data": {
"bookmarks": {
"edges": [
{
"node": {
"name": "Travel tips",
"url": "https://www.traveltips.test",
"category": {"name": "Travel", "color": "#ed008c"},
"tags": ["travel", "tips", "howto"],
}
},
{
"node": {
"name": "DIY vacation",
"url": "https://www.diyvacation.test",
"category": {"name": "Travel", "color": "#ed008c"},
"tags": ["travel", "diy", "holiday", "vacation"],
}
},
]
}
}
}
client = Client(schema)
result = client.execute(query)
assert result == expected
def test_bookmarks_filter_items_query(fixtures_data):
query = """
{
bookmarks(first: 1, name: "Awesome python"){
edges {
node {
name
url
category {
name
color
}
tags
}
}
}
}"""
expected = {
"data": {
"bookmarks": {
"edges": [
{
"node": {
"name": "Awesome python",
"url": "https://awesomelists.top/#repos/vinta/awesome-python",
"category": {"name": "Work", "color": "#1769ff"},
"tags": ["python", "dev", "awesome", "tutorial"],
}
}
]
}
}
}
client = Client(schema)
result = client.execute(query)
assert result == expected