Beispiel #1
0
 def test_if_returns_error_on_empty_post(self):
     view = BlogViewSet.as_view({'post': 'create'})
     response = self._get_create_response("{}", view)
     self.assertEqual(400, response.status_code)
     expected = [{
         'detail': 'Received document does not contain primary data',
         'status': '400',
         'source': {
             'pointer': '/data'
         },
         'code': 'parse_error',
     }]
     self.assertEqual(expected, response.data)
Beispiel #2
0
 def test_if_returns_error_on_empty_post(self):
     view = BlogViewSet.as_view({"post": "create"})
     response = self._get_create_response("{}", view)
     self.assertEqual(400, response.status_code)
     expected = [{
         "detail": "Received document does not contain primary data",
         "status": "400",
         "source": {
             "pointer": "/data"
         },
         "code": "parse_error",
     }]
     self.assertEqual(expected, response.data)
Beispiel #3
0
 def test_if_returns_error_on_missing_form_data_post(self):
     view = BlogViewSet.as_view({'post': 'create'})
     response = self._get_create_response(
         '{"data":{"attributes":{},"type":"blogs"}}', view)
     self.assertEqual(400, response.status_code)
     expected = [{
         'status': '400',
         'detail': 'This field is required.',
         'source': {
             'pointer': '/data/attributes/name'
         },
         'code': 'required',
     }]
     self.assertEqual(expected, response.data)
Beispiel #4
0
 def test_if_returns_error_on_missing_form_data_post(self):
     view = BlogViewSet.as_view({"post": "create"})
     response = self._get_create_response(
         '{"data":{"attributes":{},"type":"blogs"}}', view)
     self.assertEqual(400, response.status_code)
     expected = [{
         "status": "400",
         "detail": "This field is required.",
         "source": {
             "pointer": "/data/attributes/name"
         },
         "code": "required",
     }]
     self.assertEqual(expected, response.data)
Beispiel #5
0
 def test_if_returns_error_on_bad_endpoint_name(self):
     view = BlogViewSet.as_view({'post': 'create'})
     response = self._get_create_response(
         '{"data":{"attributes":{},"type":"bad"}}', view)
     self.assertEqual(409, response.status_code)
     expected = [{
         'detail':
         ("The resource object's type (bad) is not the type that constitute the collection "
          "represented by the endpoint (blogs)."),
         'source': {
             'pointer': '/data'
         },
         'status':
         '409',
         'code':
         'error',
     }]
     self.assertEqual(expected, response.data)
Beispiel #6
0
 def test_if_returns_error_on_bad_endpoint_name(self):
     view = BlogViewSet.as_view({"post": "create"})
     response = self._get_create_response(
         '{"data":{"attributes":{},"type":"bad"}}', view)
     self.assertEqual(409, response.status_code)
     expected = [{
         "detail":
         ("The resource object's type (bad) is not the type that constitute the collection "
          "represented by the endpoint (blogs)."),
         "source": {
             "pointer": "/data"
         },
         "status":
         "409",
         "code":
         "error",
     }]
     self.assertEqual(expected, response.data)
Beispiel #7
0
router.register(r'blogs', BlogViewSet)
router.register(r'entries', EntryViewSet)
router.register(r'nopage-entries', NonPaginatedEntryViewSet, 'nopage-entry')
router.register(r'authors', AuthorViewSet)
router.register(r'comments', CommentViewSet)
router.register(r'companies', CompanyViewset)
router.register(r'projects', ProjectViewset)
router.register(r'project-types', ProjectTypeViewset)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/$',
        EntryViewSet.as_view({'get': 'list'}),
        name='entry-suggested'),
    url(r'entries/(?P<entry_pk>[^/.]+)/blog$',
        BlogViewSet.as_view({'get': 'retrieve'}),
        name='entry-blog'),
    url(r'entries/(?P<entry_pk>[^/.]+)/comments$',
        CommentViewSet.as_view({'get': 'list'}),
        name='entry-comments'),
    url(r'entries/(?P<entry_pk>[^/.]+)/authors$',
        AuthorViewSet.as_view({'get': 'list'}),
        name='entry-authors'),
    url(r'entries/(?P<entry_pk>[^/.]+)/featured$',
        EntryViewSet.as_view({'get': 'retrieve'}),
        name='entry-featured'),
    url(r'^authors/(?P<pk>[^/.]+)/(?P<related_field>\w+)/$',
        AuthorViewSet.as_view({'get': 'retrieve_related'}),
        name='author-related'),
    url(r'^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$',
        EntryRelationshipView.as_view(),
Beispiel #8
0
router.register(r"project-types", ProjectTypeViewset)
router.register(r"lab-results", LabResultViewSet)

# for the old tests
router.register(r"identities", Identity)

urlpatterns = [
    # old tests
    re_path(
        r"identities/default/(?P<pk>\d+)$",
        GenericIdentity.as_view(),
        name="user-default",
    ),
    re_path(
        r"^entries/(?P<entry_pk>[^/.]+)/blog$",
        BlogViewSet.as_view({"get": "retrieve"}),
        name="entry-blog",
    ),
    re_path(
        r"^entries/(?P<entry_pk>[^/.]+)/comments$",
        CommentViewSet.as_view({"get": "list"}),
        name="entry-comments",
    ),
    re_path(
        r"^entries/(?P<entry_pk>[^/.]+)/suggested/$",
        EntryViewSet.as_view({"get": "list"}),
        name="entry-suggested",
    ),
    re_path(
        r"^drf-entries/(?P<entry_pk>[^/.]+)/suggested/$",
        DRFEntryViewSet.as_view({"get": "list"}),
router.register(r'entries', EntryViewSet)
router.register(r'nopage-entries', NonPaginatedEntryViewSet, 'nopage-entry')
router.register(r'authors', AuthorViewSet)
router.register(r'comments', CommentViewSet)
router.register(r'companies', CompanyViewset)
router.register(r'projects', ProjectViewset)
router.register(r'project-types', ProjectTypeViewset)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/',
        EntryViewSet.as_view({'get': 'list'}),
        name='entry-suggested'
        ),
    url(r'entries/(?P<entry_pk>[^/.]+)/blog',
        BlogViewSet.as_view({'get': 'retrieve'}),
        name='entry-blog'),
    url(r'entries/(?P<entry_pk>[^/.]+)/comments',
        CommentViewSet.as_view({'get': 'list'}),
        name='entry-comments'),
    url(r'entries/(?P<entry_pk>[^/.]+)/authors',
        AuthorViewSet.as_view({'get': 'list'}),
        name='entry-authors'),
    url(r'entries/(?P<entry_pk>[^/.]+)/featured',
        EntryViewSet.as_view({'get': 'retrieve'}),
        name='entry-featured'),

    url(r'^authors/(?P<pk>[^/.]+)/(?P<related_field>\w+)/$',
        AuthorViewSet.as_view({'get': 'retrieve_related'}),
        name='author-related'),