Add a test case for wsattr default
Change-Id: Icb3a9456a52c74af004c749ba247df1ddaf73d19 Fixes-Bug: #1227039
This commit is contained in:
parent
17adf7d4c6
commit
33d7aabf41
@ -236,6 +236,23 @@ class TestController(unittest.TestCase):
|
|||||||
headers={'Accept': 'application/json'})
|
headers={'Accept': 'application/json'})
|
||||||
self.assertEqual(res.status_int, 400)
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
|
def test_wsattr_default(self):
|
||||||
|
class ComplexType(object):
|
||||||
|
attr = wsme.types.wsattr(wsme.types.Enum(str, 'or', 'and'),
|
||||||
|
default='and')
|
||||||
|
|
||||||
|
class MyRoot(WSRoot):
|
||||||
|
@expose(int)
|
||||||
|
@validate(ComplexType)
|
||||||
|
def clx(self, a):
|
||||||
|
return a.attr
|
||||||
|
|
||||||
|
r = MyRoot(['restjson'])
|
||||||
|
app = webtest.TestApp(r.wsgiapp())
|
||||||
|
res = app.post_json('/clx', params={}, expect_errors=True,
|
||||||
|
headers={'Accept': 'application/json'})
|
||||||
|
self.assertEqual(res.status_int, 400)
|
||||||
|
|
||||||
def test_wsproperty_mandatory(self):
|
def test_wsproperty_mandatory(self):
|
||||||
class ComplexType(object):
|
class ComplexType(object):
|
||||||
def foo(self):
|
def foo(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user