def test_06_package_to_api2_with_relationship(self):
context = {"model": model,
"session": model.Session}
pkg = model.Session.query(model.Package).filter_by(name='homer').one()
as_dict = pkg.as_dict(ref_package_by='id', ref_group_by='id')
as_dict['license_title'] = None
as_dict['num_tags'] = 0
as_dict['num_resources'] = 0
dictize = package_to_api2(pkg, context)
as_dict["relationships"].sort(key=lambda x:x.items())
dictize["relationships"].sort(key=lambda x:x.items())
# the is_dict method doesn't care about organizations
del dictize['organization']
as_dict_string = pformat(as_dict)
dictize_string = pformat(dictize)
print as_dict_string
print dictize_string
assert as_dict == dictize, "\n".join(unified_diff(as_dict_string.split("\n"), dictize_string.split("\n")))
评论列表
文章目录