def test_as_dict(self):
"""
Tests that the as_dict() function returns the correct
dictionary shape.
"""
search_query = SearchQuery('@source=test_database.test_posts test')
distillery_results_list = self._get_instance(search_query)
factory = RequestFactory()
request = factory.get('/api/v1/search/')
self.assertEqual(distillery_results_list.as_dict(request), {
'count': 1,
'results': [{
'count': 1,
'next': None,
'previous': None,
'results': MOCK_RESULTS_LIST,
'distillery': {
'id': 1,
'name': 'mongodb.test_database.test_posts',
'url': 'http://testserver/api/v1/distilleries/1/',
}
}]
})
test_distillery_search_results.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录