Skip to content

Commit 69bee24

Browse files
author
Joel Collins
committed
Updated tests for view tags as sets
1 parent f3d7555 commit 69bee24

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

tests/test_server_decorators.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ def func():
123123

124124
def test_thing_action(empty_cls):
125125
wrapped_cls = decorators.thing_action(empty_cls)
126-
assert wrapped_cls.__apispec__["tags"] == ["actions"]
127-
assert wrapped_cls.__apispec__["_groups"] == ["actions"]
126+
assert wrapped_cls.__apispec__["tags"] == set(["actions"])
128127

129128

130129
def test_safe(empty_cls):
@@ -139,14 +138,12 @@ def test_idempotent(empty_cls):
139138

140139
def test_thing_property(view_cls):
141140
wrapped_cls = decorators.thing_property(view_cls)
142-
assert wrapped_cls.__apispec__["tags"] == ["properties"]
143-
assert wrapped_cls.__apispec__["_groups"] == ["properties"]
141+
assert wrapped_cls.__apispec__["tags"] == set(["properties"])
144142

145143

146144
def test_thing_property_empty_class(empty_cls, app_ctx):
147145
wrapped_cls = decorators.thing_property(empty_cls)
148-
assert wrapped_cls.__apispec__["tags"] == ["properties"]
149-
assert wrapped_cls.__apispec__["_groups"] == ["properties"]
146+
assert wrapped_cls.__apispec__["tags"] == set(["properties"])
150147

151148

152149
def test_thing_property_property_notify(view_cls, app_ctx):
@@ -312,12 +309,12 @@ def test_doc(empty_cls):
312309

313310
def test_tag(empty_cls):
314311
wrapped_cls = decorators.tag(["tag", "tag2"])(empty_cls)
315-
assert wrapped_cls.__apispec__["tags"] == ["tag", "tag2"]
312+
assert wrapped_cls.__apispec__["tags"] == set(["tag", "tag2"])
316313

317314

318315
def test_tag_single(empty_cls):
319316
wrapped_cls = decorators.tag("tag")(empty_cls)
320-
assert wrapped_cls.__apispec__["tags"] == ["tag"]
317+
assert wrapped_cls.__apispec__["tags"] == set(["tag"])
321318

322319

323320
def test_tag_invalid(empty_cls):

tests/test_server_default_views.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
import gevent
44

55

6-
def test_docs(thing, thing_client):
6+
def test_docs(thing, thing_client, schemas_path):
7+
78
with thing_client as c:
8-
assert c.get("/docs/swagger").json == thing.spec.to_dict()
9+
json_out = c.get("/docs/swagger").json
10+
assert "openapi" in json_out
11+
assert "paths" in json_out
12+
assert "info" in json_out
913
assert c.get("/docs/swagger-ui").status_code == 200
1014

1115

tests/test_server_labthing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def get(self):
6161

6262

6363
def test_add_view_action(thing, view_cls, client):
64-
view_cls.__apispec__ = {"_groups": ["actions"]}
64+
view_cls.__apispec__ = {"tags": set(["actions"])}
6565
thing.add_view(view_cls, "/index", endpoint="index")
6666
assert view_cls in thing._action_views.values()
6767

6868

6969
def test_add_view_property(thing, view_cls, client):
70-
view_cls.__apispec__ = {"_groups": ["properties"]}
70+
view_cls.__apispec__ = {"tags": set(["properties"])}
7171
thing.add_view(view_cls, "/index", endpoint="index")
7272
assert view_cls in thing._property_views.values()
7373

tests/test_server_spec_apispec.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def post(self):
9494
"post": {
9595
"description": None,
9696
"summary": None,
97-
"tags": [],
97+
"tags": set(),
9898
"responses": {200: {"description": "OK"}},
9999
},
100100
"get": {
101101
"description": None,
102102
"summary": None,
103-
"tags": [],
103+
"tags": set(),
104104
"responses": {200: {"description": "OK"}},
105105
},
106106
}
@@ -122,19 +122,19 @@ def post(self):
122122
"get": {
123123
"description": None,
124124
"summary": None,
125-
"tags": [],
125+
"tags": set(),
126126
"responses": {200: {"description": "OK"}},
127127
},
128128
"post": {
129129
"description": None,
130130
"summary": None,
131-
"tags": [],
131+
"tags": set(),
132132
"responses": {200: {"description": "OK"}},
133133
},
134134
},
135135
"description": None,
136136
"summary": None,
137-
"tags": [],
137+
"tags": set(),
138138
}
139139

140140

@@ -154,7 +154,7 @@ def post(self):
154154
"get": {
155155
"description": None,
156156
"summary": None,
157-
"tags": [],
157+
"tags": set(),
158158
"responses": {200: {"description": "OK"}},
159159
"parameters": [
160160
{
@@ -168,7 +168,7 @@ def post(self):
168168
"post": {
169169
"description": None,
170170
"summary": None,
171-
"tags": [],
171+
"tags": set(),
172172
"responses": {200: {"description": "OK"}},
173173
"parameters": [
174174
{
@@ -182,7 +182,7 @@ def post(self):
182182
},
183183
"description": None,
184184
"summary": None,
185-
"tags": [],
185+
"tags": set(),
186186
}
187187

188188

@@ -202,13 +202,13 @@ def get(self):
202202
"get": {
203203
"description": None,
204204
"summary": "A class summary",
205-
"tags": [],
205+
"tags": set(),
206206
"responses": {200: {"description": "OK"}},
207207
}
208208
},
209209
"description": None,
210210
"summary": "A class summary",
211-
"tags": [],
211+
"tags": set(),
212212
}
213213

214214

@@ -228,11 +228,11 @@ def get(self):
228228
"get": {
229229
"description": None,
230230
"summary": "A GET summary",
231-
"tags": [],
231+
"tags": set(),
232232
"responses": {200: {"description": "OK"}},
233233
}
234234
},
235235
"description": None,
236236
"summary": None,
237-
"tags": [],
237+
"tags": set(),
238238
}

0 commit comments

Comments
 (0)