コード例 #1
0
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())
コード例 #2
0
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())