@@ -10,40 +10,6 @@ def thing_description(thing):
10
10
return thing .thing_description
11
11
12
12
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
-
47
13
def test_td_init (helpers , thing_description , app_ctx , schemas_path ):
48
14
assert thing_description
49
15
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
98
64
def test_td_action_with_schema (
99
65
helpers , app , thing_description , view_cls , app_ctx , schemas_path
100
66
):
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"
105
69
106
70
app .add_url_rule ("/" , view_func = view_cls .as_view ("index" ))
107
71
rules = app .url_map ._rules_by_endpoint ["index" ]
@@ -110,9 +74,19 @@ def test_td_action_with_schema(
110
74
111
75
with app_ctx .test_request_context ():
112
76
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
+ },
116
90
"@type" : "ToggleAction" ,
117
91
}
118
92
helpers .validate_thing_description (thing_description , app_ctx , schemas_path )
0 commit comments