Ejemplo n.º 1
0
def test_delete_single_failure():
    view = TestDataDetailRestView()
    view.object = Mock()
    view.object.delete.side_effect = Exception
    result = view.delete(None)
    view.object.delete.assert_called_once_with()
    assert_equal(result, False)
Ejemplo n.º 2
0
# pylint: disable=no-value-for-parameter
from django.conf.urls import patterns, url

from rest_test_data.views import TestDataModelRestView, TestDataDetailRestView, TestDataSearchRestView

urlpatterns = patterns(
    "",
    url(r"^(?P<app>[^/]+)/(?P<model>[^/]+)/$", TestDataModelRestView.as_view(), name="objects"),
    url(r"^(?P<app>[^/]+)/(?P<model>[^/]+)/search/$", TestDataSearchRestView.as_view(), name="search"),
    url(r"^(?P<app>[^/]+)/(?P<model>[^/]+)/(?P<pk>\d+)/$", TestDataDetailRestView.as_view(), name="object"),
)
Ejemplo n.º 3
0
def test_delete_single():
    view = TestDataDetailRestView()
    view.object = Mock()
    result = view.delete(None)
    view.object.delete.assert_called_once_with()
    assert_equal(result, True)
Ejemplo n.º 4
0
def test_get_single(serializer):
    view = TestDataDetailRestView()
    view.object = Mock()
    result = view.get(None)
    serializer.serialize.assert_called_once_with([view.object])
    assert_equal(result, serializer.serialize())