Add document state action view test
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -121,6 +121,8 @@
|
|||||||
* Update OCR links activation.
|
* Update OCR links activation.
|
||||||
* Update document parsing link activation.
|
* Update document parsing link activation.
|
||||||
* Add favorite document views tests.
|
* Add favorite document views tests.
|
||||||
|
* Add document state action view test.
|
||||||
|
|
||||||
3.1.11 (2019-04-XX)
|
3.1.11 (2019-04-XX)
|
||||||
===================
|
===================
|
||||||
* Fix multiple tag selection wizard step.
|
* Fix multiple tag selection wizard step.
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ Other changes
|
|||||||
* Update OCR links activation.
|
* Update OCR links activation.
|
||||||
* Update document parsing link activation.
|
* Update document parsing link activation.
|
||||||
* Add favorite document views tests.
|
* Add favorite document views tests.
|
||||||
|
* Add document state action view test.
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
--------
|
--------
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from ..classes import WorkflowAction
|
||||||
from ..models import Workflow
|
from ..models import Workflow
|
||||||
|
|
||||||
from .literals import (
|
from .literals import (
|
||||||
@@ -11,6 +12,21 @@ from .literals import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestWorkflowAction(WorkflowAction):
|
||||||
|
label = 'test workflow state action'
|
||||||
|
|
||||||
|
|
||||||
|
class WorkflowStateActionTestMixin(object):
|
||||||
|
TestWorkflowAction = TestWorkflowAction
|
||||||
|
test_workflow_state_action_path = 'mayan.apps.document_states.tests.mixins.TestWorkflowAction'
|
||||||
|
|
||||||
|
def _create_test_workflow_state_action(self):
|
||||||
|
self.test_workflow_state.actions.create(
|
||||||
|
label=self.TestWorkflowAction.label,
|
||||||
|
action_path=self.test_workflow_state_action_path
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowTestMixin(object):
|
class WorkflowTestMixin(object):
|
||||||
def _create_test_workflow(self, add_document_type=False):
|
def _create_test_workflow(self, add_document_type=False):
|
||||||
self.test_workflow = Workflow.objects.create(
|
self.test_workflow = Workflow.objects.create(
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from mayan.apps.common.tests import GenericViewTestCase
|
||||||
|
|
||||||
|
from ..permissions import permission_workflow_edit
|
||||||
|
|
||||||
|
from .mixins import WorkflowStateActionTestMixin, WorkflowTestMixin
|
||||||
|
|
||||||
|
|
||||||
|
class WorkflowStateActionViewTestCase(WorkflowStateActionTestMixin, WorkflowTestMixin, GenericViewTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(WorkflowStateActionViewTestCase, self).setUp()
|
||||||
|
self._create_test_workflow()
|
||||||
|
self._create_test_workflow_state()
|
||||||
|
|
||||||
|
def _request_test_document_state_action_view(self):
|
||||||
|
return self.get(
|
||||||
|
viewname='document_states:setup_workflow_state_action_list',
|
||||||
|
kwargs={'pk': self.test_workflow_state.pk}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_workflow_state_action_list_view_no_permission(self):
|
||||||
|
self._create_test_workflow_state_action()
|
||||||
|
|
||||||
|
response = self._request_test_document_state_action_view()
|
||||||
|
self.assertNotContains(
|
||||||
|
response=response, text=self.TestWorkflowAction.label,
|
||||||
|
status_code=200
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_workflow_state_action_list_view_with_access(self):
|
||||||
|
self._create_test_workflow_state_action()
|
||||||
|
|
||||||
|
self.grant_access(
|
||||||
|
obj=self.test_workflow, permission=permission_workflow_edit
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self._request_test_document_state_action_view()
|
||||||
|
self.assertContains(
|
||||||
|
response=response, text=self.TestWorkflowAction.label,
|
||||||
|
status_code=200
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user