5
5
import pytest
6
6
from apispec import APISpec
7
7
from apispec .ext .marshmallow import MarshmallowPlugin
8
- from flask import Flask
8
+ from flask import Flask , abort
9
9
from flask .testing import FlaskClient
10
10
from flask .views import MethodView
11
11
from marshmallow import validate
@@ -188,7 +188,7 @@ class TestAction(ActionView):
188
188
def post (self ):
189
189
return "POST"
190
190
191
- thing .add_view (TestAction , "TestAction" )
191
+ thing .add_view (TestAction , "/ TestAction" )
192
192
193
193
class TestProperty (PropertyView ):
194
194
schema = {"count" : fields .Integer ()}
@@ -199,7 +199,7 @@ def get(self):
199
199
def post (self , args ):
200
200
pass
201
201
202
- thing .add_view (TestProperty , "TestProperty" )
202
+ thing .add_view (TestProperty , "/ TestProperty" )
203
203
204
204
class TestFieldProperty (PropertyView ):
205
205
schema = fields .String (validate = validate .OneOf (["one" , "two" ]))
@@ -210,7 +210,28 @@ def get(self):
210
210
def post (self , args ):
211
211
pass
212
212
213
- thing .add_view (TestFieldProperty , "TestFieldProperty" )
213
+ thing .add_view (TestFieldProperty , "/TestFieldProperty" )
214
+
215
+ class FailAction (ActionView ):
216
+ wait_for = 1.0
217
+ def post (self ):
218
+ raise Exception ("This action is meant to fail with an Exception" )
219
+
220
+ thing .add_view (FailAction , "/FailAction" )
221
+
222
+ class AbortAction (ActionView ):
223
+ wait_for = 1.0
224
+ def post (self ):
225
+ abort (418 , "I'm a teapot! This action should abort with an HTTP code 418" )
226
+
227
+ thing .add_view (AbortAction , "/AbortAction" )
228
+
229
+ class ActionWithValidation (ActionView ):
230
+ wait_for = 1.0
231
+ args = {"test_arg" : fields .String (validate = validate .OneOf (["one" , "two" ]))}
232
+ def post (self ):
233
+ return True
234
+ thing .add_view (ActionWithValidation , "/ActionWithValidation" )
214
235
215
236
return thing
216
237
0 commit comments