def test_search(serializer): view = TestDataSearchRestView() view.model = Mock() view.data = {'data': {'pk': 1}} result = view.post(None) view.model.objects.filter.assert_called_once_with(**view.data['data']) serializer.serialize.assert_called_once_with(view.model.objects.filter()) assert_equal(result, serializer.serialize())
def test_search_all(serializer): view = TestDataSearchRestView() view.model = Mock() view.data = None result = view.post(None) view.model.objects.filter.assert_called_once_with() serializer.serialize.assert_called_once_with(view.model.objects.filter()) assert_equal(result, serializer.serialize())