Skip to content

Commit e13b47d

Browse files
authored
Merge pull request #2 from p1c2u/fix/datetime-format-dependencies-fix
Datetime format dependencies fix
2 parents 44b5607 + c96183c commit e13b47d

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
isodate
12
jsonschema
23
six
4+
strict_rfc3339

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*
2323
setup_requires =
2424
setuptools
2525
install_requires =
26+
isodate
2627
jsonschema
2728
six
29+
strict_rfc3339
2830
tests_require =
2931
mock; python_version<"3.0"
3032
pytest

tests/integration/test_validators.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from jsonschema import ValidationError
2+
import mock
23
import pytest
4+
from six import u
35

4-
from openapi_schema_validator import OAS30Validator
6+
from openapi_schema_validator import OAS30Validator, oas30_format_checker
57

68

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

3032
assert result is None
33+
34+
@pytest.mark.parametrize('value', [
35+
u('1989-01-02T00:00:00Z'),
36+
u('2018-01-02T23:59:59Z'),
37+
])
38+
@mock.patch(
39+
'openapi_schema_validator._format.'
40+
'DATETIME_HAS_STRICT_RFC3339', True
41+
)
42+
@mock.patch(
43+
'openapi_schema_validator._format.'
44+
'DATETIME_HAS_ISODATE', False
45+
)
46+
def test_string_format_datetime_strict_rfc3339(self, value):
47+
schema = {"type": 'string', "format": 'date-time'}
48+
validator = OAS30Validator(
49+
schema, format_checker=oas30_format_checker)
50+
51+
result = validator.validate(value)
52+
53+
assert result is None
54+
55+
@pytest.mark.parametrize('value', [
56+
u('1989-01-02T00:00:00Z'),
57+
u('2018-01-02T23:59:59Z'),
58+
])
59+
@mock.patch(
60+
'openapi_schema_validator._format.'
61+
'DATETIME_HAS_STRICT_RFC3339', False
62+
)
63+
@mock.patch(
64+
'openapi_schema_validator._format.'
65+
'DATETIME_HAS_ISODATE', True
66+
)
67+
def test_string_format_datetime_isodate(self, value):
68+
schema = {"type": 'string', "format": 'date-time'}
69+
validator = OAS30Validator(
70+
schema, format_checker=oas30_format_checker)
71+
72+
result = validator.validate(value)
73+
74+
assert result is None

0 commit comments

Comments
 (0)