From 33d7aabf418b7be4bf21ce2fa311e8fd0a54eb17 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 18 Sep 2013 17:25:46 +0200 Subject: [PATCH] Add a test case for wsattr default Change-Id: Icb3a9456a52c74af004c749ba247df1ddaf73d19 Fixes-Bug: #1227039 --- wsme/tests/test_api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wsme/tests/test_api.py b/wsme/tests/test_api.py index b53be6f..e27cf69 100644 --- a/wsme/tests/test_api.py +++ b/wsme/tests/test_api.py @@ -236,6 +236,23 @@ class TestController(unittest.TestCase): headers={'Accept': 'application/json'}) 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): class ComplexType(object): def foo(self):