-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_schema_test.py
More file actions
41 lines (39 loc) · 1.03 KB
/
json_schema_test.py
File metadata and controls
41 lines (39 loc) · 1.03 KB
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
34
35
36
37
38
39
40
41
from content_api.json_schema import writable_schema, writable_doc
def test_writable_schema():
schema = {
'type': 'object',
'properties': {
'id': {'type': 'integer', 'x-meta': {'writable': False}},
'title': {'type': 'string'}
},
'required': ['id', 'title']
}
expected_schema = {
'type': 'object',
'properties': {
'title': {'type': 'string'}
},
'required': ['title']
}
assert writable_schema(None) == None
assert writable_schema({'type': 'string'}) == {'type': 'string'}
assert writable_schema(schema) == expected_schema
def test_writable_doc():
schema = {
'type': 'object',
'properties': {
'id': {'type': 'integer', 'x-meta': {'writable': False}},
'title': {'type': 'string'}
},
'required': ['id', 'title']
}
doc = {
'id': 'the-id',
'title': 'the title'
}
expected_doc = {
'title': 'the title'
}
assert writable_doc(schema, None) == None
assert writable_doc(None, doc) == doc
assert writable_doc(schema, doc) == expected_doc