Skip to content

Commit 5d2be38

Browse files
author
Joel Collins
committed
Updated TD tests
1 parent 097f506 commit 5d2be38

File tree

1 file changed

+15
-41
lines changed

1 file changed

+15
-41
lines changed

tests/test_server_spec_td.py

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,6 @@ def thing_description(thing):
1010
return thing.thing_description
1111

1212

13-
def test_find_schema_for_view_readonly():
14-
class ViewClass:
15-
def get(self):
16-
pass
17-
18-
ViewClass.get.__apispec__ = {"_schema": {200: "schema"}}
19-
assert td.find_schema_for_view(ViewClass) == "schema"
20-
21-
22-
def test_find_schema_for_view_writeonly_post():
23-
class ViewClass:
24-
def post(self):
25-
pass
26-
27-
ViewClass.post.__apispec__ = {"_params": "params"}
28-
assert td.find_schema_for_view(ViewClass) == "params"
29-
30-
31-
def test_find_schema_for_view_writeonly_put():
32-
class ViewClass:
33-
def put(self):
34-
pass
35-
36-
ViewClass.put.__apispec__ = {"_params": "params"}
37-
assert td.find_schema_for_view(ViewClass) == "params"
38-
39-
40-
def test_find_schema_for_view_none():
41-
class ViewClass:
42-
pass
43-
44-
assert td.find_schema_for_view(ViewClass) == {}
45-
46-
4713
def test_td_init(helpers, thing_description, app_ctx, schemas_path):
4814
assert thing_description
4915
helpers.validate_thing_description(thing_description, app_ctx, schemas_path)
@@ -98,10 +64,8 @@ def test_td_action(helpers, app, thing_description, view_cls, app_ctx, schemas_p
9864
def test_td_action_with_schema(
9965
helpers, app, thing_description, view_cls, app_ctx, schemas_path
10066
):
101-
view_cls.post.__apispec__ = {
102-
"_params": {"integer": fields.Int()},
103-
"@type": "ToggleAction",
104-
}
67+
view_cls.args = {"integer": fields.Int()}
68+
view_cls.semtype = "ToggleAction"
10569

10670
app.add_url_rule("/", view_func=view_cls.as_view("index"))
10771
rules = app.url_map._rules_by_endpoint["index"]
@@ -110,9 +74,19 @@ def test_td_action_with_schema(
11074

11175
with app_ctx.test_request_context():
11276
assert "index" in thing_description.to_dict().get("actions")
113-
assert thing_description.to_dict().get("actions").get("index").get("input") == {
114-
"type": "object",
115-
"properties": {"integer": {"type": "integer", "format": "int32"}},
77+
assert thing_description.to_dict().get("actions").get("index") == {
78+
"title": "ViewClass",
79+
"description": "",
80+
"links": [{"href": "/"}],
81+
"safe": False,
82+
"idempotent": False,
83+
"forms": [
84+
{"op": ["invokeaction"], "href": "/", "contentType": "application/json"}
85+
],
86+
"input": {
87+
"type": "object",
88+
"properties": {"integer": {"type": "integer", "format": "int32"}},
89+
},
11690
"@type": "ToggleAction",
11791
}
11892
helpers.validate_thing_description(thing_description, app_ctx, schemas_path)

0 commit comments

Comments
 (0)