Skip to content

Commit 69125d1

Browse files
author
Chris Hand
committed
Add unit tests for invalid choice values
1 parent aae71ad commit 69125d1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_post.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)