Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
isodate
jsonschema
six
strict_rfc3339
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
setup_requires =
setuptools
install_requires =
isodate
jsonschema
six
strict_rfc3339
tests_require =
mock; python_version<"3.0"
pytest
Expand Down
46 changes: 45 additions & 1 deletion tests/integration/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from jsonschema import ValidationError
import mock
import pytest
from six import u

from openapi_schema_validator import OAS30Validator
from openapi_schema_validator import OAS30Validator, oas30_format_checker


class TestOAS30ValidatorValidate(object):
Expand All @@ -28,3 +30,45 @@ def test_nullable(self, schema_type):
result = validator.validate(value)

assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
])
@mock.patch(
'openapi_schema_validator._format.'
'DATETIME_HAS_STRICT_RFC3339', True
)
@mock.patch(
'openapi_schema_validator._format.'
'DATETIME_HAS_ISODATE', False
)
def test_string_format_datetime_strict_rfc3339(self, value):
schema = {"type": 'string', "format": 'date-time'}
validator = OAS30Validator(
schema, format_checker=oas30_format_checker)

result = validator.validate(value)

assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
])
@mock.patch(
'openapi_schema_validator._format.'
'DATETIME_HAS_STRICT_RFC3339', False
)
@mock.patch(
'openapi_schema_validator._format.'
'DATETIME_HAS_ISODATE', True
)
def test_string_format_datetime_isodate(self, value):
schema = {"type": 'string', "format": 'date-time'}
validator = OAS30Validator(
schema, format_checker=oas30_format_checker)

result = validator.validate(value)

assert result is None