mirror of
https://github.com/correl/openapi-core.git
synced 2025-01-01 11:03:19 +00:00
UUID string format tests
This commit is contained in:
parent
dadf075670
commit
48d1d1c8ae
3 changed files with 28 additions and 0 deletions
|
@ -317,6 +317,9 @@ components:
|
|||
required:
|
||||
- rootCause
|
||||
properties:
|
||||
correlationId:
|
||||
type: string
|
||||
format: uuid
|
||||
rootCause:
|
||||
type: string
|
||||
suberror:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import pytest
|
||||
from uuid import UUID
|
||||
from six import iteritems
|
||||
|
||||
from openapi_core.extensions.models.models import BaseModel
|
||||
|
@ -1154,11 +1155,13 @@ class TestPetstore(object):
|
|||
|
||||
code = 400
|
||||
message = 'Bad request'
|
||||
correlationId = UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
|
||||
rootCause = 'Tag already exist'
|
||||
additionalinfo = 'Tag Dog already exist'
|
||||
data_json = {
|
||||
'code': code,
|
||||
'message': message,
|
||||
'correlationId': str(correlationId),
|
||||
'rootCause': rootCause,
|
||||
'additionalinfo': additionalinfo,
|
||||
}
|
||||
|
@ -1171,5 +1174,6 @@ class TestPetstore(object):
|
|||
assert isinstance(response_result.data, BaseModel)
|
||||
assert response_result.data.code == code
|
||||
assert response_result.data.message == message
|
||||
assert response_result.data.correlationId == correlationId
|
||||
assert response_result.data.rootCause == rootCause
|
||||
assert response_result.data.additionalinfo == additionalinfo
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
@ -416,6 +417,26 @@ class TestSchemaValidate(object):
|
|||
|
||||
assert result == value
|
||||
|
||||
@pytest.mark.parametrize('value', [
|
||||
uuid.UUID('{12345678-1234-5678-1234-567812345678}'),
|
||||
])
|
||||
def test_string_format_uuid(self, value):
|
||||
schema = Schema('string', schema_format='uuid')
|
||||
|
||||
result = schema.validate(value)
|
||||
|
||||
assert result == value
|
||||
|
||||
@pytest.mark.parametrize('value', [
|
||||
b('true'), u('true'), False, 1, 3.14, [1, 3],
|
||||
datetime.date(2018, 1, 2), datetime.datetime(2018, 1, 2, 23, 59, 59),
|
||||
])
|
||||
def test_string_format_uuid_invalid(self, value):
|
||||
schema = Schema('string', schema_format='uuid')
|
||||
|
||||
with pytest.raises(InvalidSchemaValue):
|
||||
schema.validate(value)
|
||||
|
||||
@pytest.mark.parametrize('value', [
|
||||
b('true'), u('true'), False, 1, 3.14, [1, 3],
|
||||
datetime.date(1989, 1, 2),
|
||||
|
|
Loading…
Reference in a new issue