def it_serializes_errors(self): expected = { 'collection': { 'error': { 'title': 'Error title', 'code': 404, 'message': 'Not found' } } } j = CollectionJsonSerializer.error(status=404, message='Not found', title='Error title') eq_(expected, json.loads(j))
def it_serializes_a_document_to_json(self): article = article_factory() expected = { 'collection': { 'items': [{ 'data': [ {'name': 'slug', 'value': 'article-slug'}, {'name': 'title', 'value': 'article title'} ], 'links': [ {'href': 'editor-uri', 'rel': 'item'} ], 'href': 'article-uri' } ]} } eq_(expected, json.loads(CollectionJsonSerializer.dump(article)))