def test_serializes_root_scalars(self, native_object): d = DictionaryObject.to_dict(native_object) assert d["dict_integer_value"] == fake_dict_integer_value assert d["dict_float_value"] == fake_dict_float_value assert d["dict_string_avlue"] == fake_dict_string_value assert d["dict_boolean_value"] == fake_dict_boolean_value assert d["dict_none_value"] == fake_dict_none_value assert d["dict_timedelta_value"] == str(fake_dict_timedelta_value) assert d["dict_datetime_value"] == str(fake_dict_datetime_value)
def test_serializes_sub_scalars(self, native_object): d = DictionaryObject.to_dict(native_object) assert d["sub_object"]["sub_integer_value"] == fake_sub_integer_value assert d["sub_object"]["sub_float_value"] == fake_sub_float_value assert d["sub_object"]["sub_string_value"] == fake_sub_string_value assert d["sub_object"]["sub_boolean_value"] == fake_sub_boolean_value assert d["sub_object"]["sub_none_value"] == fake_sub_none_value assert d["sub_object"]["sub_timedelta_value"] == str( fake_sub_timedelta_value) assert d["sub_object"]["sub_datetime_value"] == str( fake_sub_datetime_value)
def test_recurses(self, native_object): native_object.sub_object.sub = SimpleObject() native_object.sub_object.sub.level = 1 native_object.sub_object.sub.sub = SimpleObject() native_object.sub_object.sub.sub.level = 2 native_object.sub_object.sub.sub.sub = SimpleObject() native_object.sub_object.sub.sub.sub.level = 3 native_object.sub_object.sub.sub.sub.sub = SimpleObject() native_object.sub_object.sub.sub.sub.sub.level = 3 d = DictionaryObject.to_dict(native_object) assert isinstance(d["sub_object"]["sub"], dict) assert d["sub_object"]["sub"]["level"] == 1 assert isinstance(d["sub_object"]["sub"]["sub"], dict) assert d["sub_object"]["sub"]["sub"]["level"] == 2 assert isinstance(d["sub_object"]["sub"]["sub"]["sub"], dict) assert d["sub_object"]["sub"]["sub"]["sub"]["level"] == 3
def test_returns_dict(self, native_object): d = DictionaryObject.to_dict(native_object) assert isinstance(d, dict)