Skip to content
Snippets Groups Projects
Commit 6909704a authored by vlorentz's avatar vlorentz
Browse files

Check recursively that .to_dict() returns a nested dict.

parent 9f806616
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,26 @@ def test_generation(obj_type_and_obj):
attr.validate(object_)
def assert_nested_dict(obj):
"""Tests the object is a nested dict and contains no more class
from swh.model.model."""
if isinstance(obj, dict):
for (key, value) in obj.items():
assert isinstance(key, (str, bytes)), key
assert_nested_dict(value)
elif isinstance(obj, list):
for value in obj:
assert_nested_dict(value)
elif isinstance(obj, (int, float, str, bytes, bool, type(None))):
pass
else:
assert False, obj
@given(object_dicts())
def test_dicts_generation(obj_type_and_obj):
(obj_type, object_) = obj_type_and_obj
assert isinstance(object_, dict)
assert_nested_dict(object_)
if obj_type == 'content':
if object_['status'] == 'visible':
assert set(object_) == \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment