def test_as_dict(self):
"""
Tests that the correct dictionary shape is returned from the
as_dict() function.
"""
distillery = Distillery.objects.get(pk=1)
search_query = SearchQuery('test "more testing"')
distillery_results = self._get_instance(search_query, distillery)
factory = RequestFactory()
request = factory.get('/api/v1/search/')
self.assertDictEqual(distillery_results.as_dict(request), {
'count': 1,
'results': MOCK_RESULTS_LIST,
'next': None,
'previous': None,
'distillery': {
'id': 1,
'name': 'mongodb.test_database.test_posts',
'url': 'http://testserver/api/v1/distilleries/1/',
}
})
test_distillery_search_results.py 文件源码
python
阅读 15
收藏 0
点赞 0
评论 0
评论列表
文章目录