Add microversions schema unit test for None

This patch adds a microversions schema unit test for passing
None as min_version of schema() decorator.

Change-Id: I7d05e6331c07c659f6a97267579f154a7be269f6
This commit is contained in:
Ken'ichi Ohmichi 2015-09-10 08:24:56 +00:00
parent e6100f5934
commit 02c9c524c0
1 changed files with 23 additions and 0 deletions

View File

@ -90,6 +90,29 @@ class MicroversionsSchemaTestCase(APIValidationTestCase):
self.check_validation_error(self.post, body={'foo': 'bar'},
expected_detail=detail, req=req)
def test_validate_v2compatible_request_with_none_min_version(self):
schema_none = {
'type': 'object',
'properties': {
'foo': {
'type': 'integer'
}
}
}
@validation.schema(schema_none)
def post(req, body):
return 'Validation succeeded.'
req = FakeRequest()
req.legacy_v2 = True
self.assertEqual('Validation succeeded.',
post(body={'foo': 1}, req=req))
detail = ("Invalid input for field/attribute foo. Value: bar. "
"'bar' is not of type 'integer'")
self.check_validation_error(post, body={'foo': 'bar'},
expected_detail=detail, req=req)
class RequiredDisableTestCase(APIValidationTestCase):