Skip to content

Commit 0ef0397

Browse files
committed
Add more tests
1 parent 6d45c4a commit 0ef0397

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/unit/unmarshalling/test_unmarshal.py

+55
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,61 @@ def test_schema_any_any_of(self, unmarshaller_factory):
559559
schema = SpecPath.from_spec(spec)
560560
assert unmarshaller_factory(schema)(['hello']) == ['hello']
561561

562+
def test_schema_object_any_of(self, unmarshaller_factory):
563+
spec = {
564+
'type': 'object',
565+
'anyOf': [
566+
{
567+
'type': 'object',
568+
'required': ['someint'],
569+
'properties': {
570+
'someint': {
571+
'type': 'integer'
572+
}
573+
}
574+
},
575+
{
576+
'type': 'object',
577+
'required': ['somestr'],
578+
'properties': {
579+
'somestr': {
580+
'type': 'string'
581+
}
582+
}
583+
}
584+
],
585+
}
586+
schema = SpecPath.from_spec(spec)
587+
assert unmarshaller_factory(schema)({'someint': 1}) == {'someint': 1}
588+
589+
def test_schema_object_any_of_invalid(self, unmarshaller_factory):
590+
spec = {
591+
'type': 'object',
592+
'anyOf': [
593+
{
594+
'type': 'object',
595+
'required': ['someint'],
596+
'properties': {
597+
'someint': {
598+
'type': 'integer'
599+
}
600+
}
601+
},
602+
{
603+
'type': 'object',
604+
'required': ['somestr'],
605+
'properties': {
606+
'somestr': {
607+
'type': 'string'
608+
}
609+
}
610+
}
611+
],
612+
}
613+
schema = SpecPath.from_spec(spec)
614+
with pytest.raises(UnmarshalError):
615+
unmarshaller_factory(schema)({'someint': '1'})
616+
562617
def test_schema_any_all_of(self, unmarshaller_factory):
563618
spec = {
564619
'allOf': [

0 commit comments

Comments
 (0)