@@ -49,14 +49,14 @@ def test_post_invalid_schema_type(self):
4949 def test_post_invalid_schema_limits (self ):
5050 # break min_length
5151 response = self .client .post ('/limiteddoc/' ,
52- data = '{"a": "hi", "b": "ho", "c": "x", "d": "<10 chars", "e": "<10 chars"}' ,
52+ data = '{"a": "hi", "b": "ho", "c": "x", "d": "<10 chars", "e": "<10 chars", "g": "val1" }' ,
5353 content_type = 'application/json' )
5454 self .assertEqual (response .status_code , POST_VALIDATION_ERROR_CODE )
5555 json_data = response .get_json ()
5656 self .assertDictEqual (json_data [config .ISSUES ], {'e' : "min length is 10" })
5757 # break max_length
5858 response = self .client .post ('/limiteddoc/' ,
59- data = '{"a": "hi", "b": "ho", "c": "x", "d": "string > 10 chars", "e": "some very long text"}' ,
59+ data = '{"a": "hi", "b": "ho", "c": "x", "d": "string > 10 chars", "e": "some very long text", "g": "val2" }' ,
6060 content_type = 'application/json' )
6161 self .assertEqual (response .status_code , POST_VALIDATION_ERROR_CODE )
6262 json_data = response .get_json ()
@@ -71,6 +71,25 @@ def test_post_invalid_schema_required(self):
7171 json_data = response .get_json ()
7272 self .assertDictEqual (json_data [config .ISSUES ], {'a' : "required field" })
7373
74+ def test_post_invalid_schema_choice (self ):
75+ response = self .client .post ('/limiteddoc/' ,
76+ data = '{"a": "hi", "b": "ho", "c": "a"}' ,
77+ content_type = 'application/json' )
78+ self .assertEqual (response .status_code , POST_VALIDATION_ERROR_CODE )
79+ json_data = response .get_json ()
80+ self .assertDictEqual (json_data [config .ISSUES ], {'c' : 'unallowed value a' })
81+ response = self .client .post ('/limiteddoc/' ,
82+ data = '{"a": "hi", "b": "ho", "g": "val4"}' ,
83+ content_type = 'application/json' )
84+ self .assertEqual (response .status_code , POST_VALIDATION_ERROR_CODE )
85+ json_data = response .get_json ()
86+ self .assertDictEqual (json_data [config .ISSUES ], {'g' : 'unallowed value val4' })
87+ response = self .client .post ('/limiteddoc/' ,
88+ data = '{"a": "hi", "b": "ho", "g": "test value 1"}' ,
89+ content_type = 'application/json' )
90+ self .assertEqual (response .status_code , POST_VALIDATION_ERROR_CODE )
91+ json_data = response .get_json ()
92+ self .assertDictEqual (json_data [config .ISSUES ], {'g' : 'unallowed value test value 1' })
7493
7594 def test_post_invalid_schema_unique (self ):
7695 response = self .client .post ('/limiteddoc/' ,
0 commit comments