-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtest_shortcut.py
33 lines (27 loc) · 886 Bytes
/
test_shortcut.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest
from openapi_schema_validator import validate
@pytest.fixture(scope="function")
def schema():
return {
"type": "object",
"properties": {
"email": {"type": "string"},
"enabled": {
"type": "boolean",
},
},
"example": {"enabled": False, "email": "[email protected]"},
}
def test_validate_does_not_add_nullable_to_schema(schema):
"""
Verify that calling validate does not add the 'nullable' key to the schema
"""
validate({"email": "[email protected]"}, schema)
assert "nullable" not in schema["properties"]["email"].keys()
def test_validate_does_not_mutate_schema(schema):
"""
Verify that calling validate does not mutate the schema
"""
original_schema = schema.copy()
validate({"email": "[email protected]"}, schema)
assert schema == original_schema