Refactor the events app API
Use viewsets for the events app API. Use new link badge support for the unread notification count display. Remove AJAX workers support now that it is now needed anymore. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from rest_framework import status
|
||||
|
||||
from mayan.apps.documents.tests.mixins import DocumentTestMixin
|
||||
from mayan.apps.rest_api.tests import BaseAPITestCase
|
||||
|
||||
from ..permissions import permission_events_view
|
||||
|
||||
from .mixins import EventTypeTestMixin
|
||||
|
||||
|
||||
@@ -12,7 +19,7 @@ class EventTypeNamespaceAPITestCase(EventTypeTestMixin, BaseAPITestCase):
|
||||
|
||||
def test_event_type_namespace_list_view(self):
|
||||
response = self.get(viewname='rest_api:event_type_namespace-list')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_event_type_namespace_event_type_list_view(self):
|
||||
response = self.get(
|
||||
@@ -22,7 +29,7 @@ class EventTypeNamespaceAPITestCase(EventTypeTestMixin, BaseAPITestCase):
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_event_type_list_view(self):
|
||||
response = self.get(
|
||||
@@ -32,4 +39,35 @@ class EventTypeNamespaceAPITestCase(EventTypeTestMixin, BaseAPITestCase):
|
||||
'event_type_id': self.test_event_type.id
|
||||
}
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
|
||||
class DocumentEventAPITestCase(DocumentTestMixin, BaseAPITestCase):
|
||||
def setUp(self):
|
||||
super(DocumentEventAPITestCase, self).setUp()
|
||||
self.test_object = self.test_document
|
||||
|
||||
def _request_object_event_list_api_view(self):
|
||||
content_type = ContentType.objects.get_for_model(
|
||||
model=self.test_object
|
||||
)
|
||||
|
||||
return self.get(
|
||||
viewname='rest_api:object-event-list',
|
||||
kwargs={
|
||||
'app_label': content_type.app_label,
|
||||
'model_name': content_type.model,
|
||||
'object_id': self.test_object.pk
|
||||
}
|
||||
)
|
||||
|
||||
def test_object_event_list_view_no_permission(self):
|
||||
response = self._request_object_event_list_api_view()
|
||||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
def test_object_event_list_view_with_access(self):
|
||||
self.grant_access(
|
||||
obj=self.test_object, permission=permission_events_view
|
||||
)
|
||||
response = self._request_object_event_list_api_view()
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
Reference in New Issue
Block a user