55import pytest
66from apispec import APISpec
77from apispec .ext .marshmallow import MarshmallowPlugin
8- from flask import Flask
8+ from flask import Flask , abort
99from flask .testing import FlaskClient
1010from flask .views import MethodView
1111from marshmallow import validate
@@ -188,7 +188,7 @@ class TestAction(ActionView):
188188 def post (self ):
189189 return "POST"
190190
191- thing .add_view (TestAction , "TestAction" )
191+ thing .add_view (TestAction , "/ TestAction" )
192192
193193 class TestProperty (PropertyView ):
194194 schema = {"count" : fields .Integer ()}
@@ -199,7 +199,7 @@ def get(self):
199199 def post (self , args ):
200200 pass
201201
202- thing .add_view (TestProperty , "TestProperty" )
202+ thing .add_view (TestProperty , "/ TestProperty" )
203203
204204 class TestFieldProperty (PropertyView ):
205205 schema = fields .String (validate = validate .OneOf (["one" , "two" ]))
@@ -210,7 +210,28 @@ def get(self):
210210 def post (self , args ):
211211 pass
212212
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" )
214235
215236 return thing
216237
0 commit comments