Пример #1
0
    def test_has_successors(self):
        task_with_successor = create(Builder('task'))
        task_without_successor = create(Builder('task'))
        create(Builder('task').successor_from(task_with_successor))

        self.assertTrue(get_checker(task_with_successor).task.has_successors)
        self.assertFalse(get_checker(task_without_successor).task.has_successors)
    def test_has_successors(self):
        task_with_successor = create(Builder('task'))
        task_without_successor = create(Builder('task'))
        create(Builder('task').successor_from(task_with_successor))

        self.assertTrue(get_checker(task_with_successor).task.has_successors)
        self.assertFalse(
            get_checker(task_without_successor).task.has_successors)
    def test_is_successor_process_checks_request_for_succesor_flag(self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertFalse(get_checker(task).request.is_successor_process)

        task.REQUEST.set('X-CREATING-SUCCESSOR', True)

        self.assertTrue(get_checker(task).request.is_successor_process)
Пример #4
0
    def test_is_responsible_checks_inbox_members_if_issuer_is_a_inbox(self):
        self.login(self.regular_user)
        self.task.responsible = get_current_org_unit().inbox().id()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_responsible)

        self.login(self.secretariat_user)
        self.assertTrue(get_checker(self.task).current_user.is_responsible)
Пример #5
0
    def test_is_responsible_checks_inbox_members_if_issuer_is_a_inbox(self):
        self.login(self.regular_user)
        self.task.responsible = get_current_org_unit().inbox().id()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_responsible)

        self.login(self.secretariat_user)
        self.assertTrue(get_checker(self.task).current_user.is_responsible)
Пример #6
0
    def test_all_subtasks_is_NOT_finished_when_cancelled_or_resolved(self):
        self.login(self.dossier_responsible)

        self.set_workflow_state('task-state-resolved', self.task)
        self.assertFalse(get_checker(self.task).task.all_subtasks_finished)

        self.set_workflow_state('task-state-cancelled', self.task)
        self.assertFalse(get_checker(self.task).task.all_subtasks_finished)
Пример #7
0
    def test_is_successor_process_checks_request_for_succesor_flag(self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertFalse(get_checker(task).request.is_successor_process)

        task.REQUEST.set('X-CREATING-SUCCESSOR', True)

        self.assertTrue(get_checker(task).request.is_successor_process)
Пример #8
0
    def test_is_remote_request_checks_ogds_plugin_flag(self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertFalse(get_checker(task).request.is_remote)

        task.REQUEST.environ['X_OGDS_AUID'] = 'rr'

        self.assertTrue(get_checker(task).request.is_remote)
    def test_is_remote_request_checks_ogds_plugin_flag(self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertFalse(get_checker(task).request.is_remote)

        task.REQUEST.environ['X_OGDS_AUID'] = 'rr'

        self.assertTrue(get_checker(task).request.is_remote)
Пример #10
0
    def test_all_subtasks_is_NOT_finished_when_cancelled_or_resolved(self):
        self.login(self.dossier_responsible)

        self.set_workflow_state('task-state-resolved', self.task)
        self.assertFalse(get_checker(self.task).task.all_subtasks_finished)

        self.set_workflow_state('task-state-cancelled', self.task)
        self.assertFalse(get_checker(self.task).task.all_subtasks_finished)
Пример #11
0
    def test_is_issuer(self):
        self.login(self.dossier_responsible)
        self.task.issuer = self.dossier_responsible.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertTrue(get_checker(self.task).current_user.is_issuer)

        self.task.issuer = self.secretariat_user.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_issuer)
Пример #12
0
    def test_is_responsible(self):
        self.login(self.dossier_responsible)
        self.task.responsible = self.dossier_responsible.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertTrue(get_checker(self.task).current_user.is_responsible)

        self.task.responsible = self.regular_user.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_responsible)
Пример #13
0
    def test_is_issuer(self):
        self.login(self.dossier_responsible)
        self.task.issuer = self.dossier_responsible.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertTrue(get_checker(self.task).current_user.is_issuer)

        self.task.issuer = self.secretariat_user.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_issuer)
Пример #14
0
    def test_is_responsible(self):
        self.login(self.dossier_responsible)
        self.task.responsible = self.dossier_responsible.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertTrue(get_checker(self.task).current_user.is_responsible)

        self.task.responsible = self.regular_user.getId()
        self.task.get_sql_object().sync_with(self.task)
        self.assertFalse(get_checker(self.task).current_user.is_responsible)
Пример #15
0
 def test_is_assigned_to_current_admin_unit(self):
     self.login(self.secretariat_user)
     self.assertTrue(get_checker(self.inbox_forwarding).task.is_assigned_to_current_admin_unit)
     additional = create(Builder('admin_unit').id(u'additional'))
     create(Builder('org_unit')
            .id(u'additional')
            .having(admin_unit=additional))
     self.inbox_forwarding.responsible_client = 'additional'
     self.inbox_forwarding.get_sql_object().sync_with(self.inbox_forwarding)
     self.assertFalse(get_checker(self.inbox_forwarding).task.is_assigned_to_current_admin_unit)
Пример #16
0
 def test_is_assigned_to_current_admin_unit(self):
     self.login(self.secretariat_user)
     self.assertTrue(
         get_checker(
             self.inbox_forwarding).task.is_assigned_to_current_admin_unit)
     additional = create(Builder('admin_unit').id(u'additional'))
     create(
         Builder('org_unit').id(u'additional').having(
             admin_unit=additional))
     self.inbox_forwarding.responsible_client = 'additional'
     self.inbox_forwarding.get_sql_object().sync_with(self.inbox_forwarding)
     self.assertFalse(
         get_checker(
             self.inbox_forwarding).task.is_assigned_to_current_admin_unit)
Пример #17
0
    def test_responsible_orgunit_agency_member_with_private_task(self):
        self.login(self.secretariat_user)
        self.task.is_private = True
        self.task.get_sql_object().sync_with(self.task)

        self.assertFalse(
            get_checker(self.task).current_user.in_responsible_orgunits_inbox_group)
Пример #18
0
 def test_all_subtasks_finished(self):
     self.login(self.dossier_responsible)
     for state in ('task-state-rejected',
                   'task-state-cancelled',
                   'task-state-tested-and-closed'):
         self.set_workflow_state(state, self.subtask)
         self.assertTrue(get_checker(self.task).task.all_subtasks_finished)
Пример #19
0
    def test_responsible_orgunit_agency_member_with_private_task(self):
        self.login(self.secretariat_user)
        self.task.is_private = True
        self.task.get_sql_object().sync_with(self.task)

        self.assertFalse(
            get_checker(
                self.task).current_user.in_responsible_orgunits_inbox_group)
Пример #20
0
    def test_is_responsible_checks_inbox_members_if_issuer_is_a_inbox(self):
        task1 = create(Builder('task')
                       .having(responsible=self.org_unit.inbox().id()))

        self.assertTrue(get_checker(task1).current_user.is_responsible)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(checker.current_user.is_responsible)
    def test_is_responsible_checks_inbox_members_if_issuer_is_a_inbox(self):
        task1 = create(
            Builder('task').having(responsible=self.org_unit.inbox().id()))

        self.assertTrue(get_checker(task1).current_user.is_responsible)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(checker.current_user.is_responsible)
Пример #22
0
 def test_issuing_orgunit_agency_member(self):
     """Checks if the current user is member of the issuing
     orgunit's inbox_group"""
     self.login(self.secretariat_user)
     self.assertTrue(
         get_checker(self.task).current_user.in_issuing_orgunits_inbox_group)
     checker = Checker(self.task.get_sql_object(), self.request, self.secretariat_user)
     self.assertFalse(checker.current_user.in_issuing_orgunits_inbox_group)
    def test_is_assigned_to_current_admin_unit(self):
        admin_unit = create(Builder('admin_unit').id('additional'))
        create(
            Builder('org_unit').id('additional').with_default_groups().having(
                title='Additional', admin_unit=admin_unit))

        task1 = create(
            Builder('forwarding').having(responsible_client='client1'))
        task2 = create(
            Builder('forwarding').having(responsible=TEST_USER_ID,
                                         issuer=TEST_USER_ID,
                                         responsible_client='additional'))

        self.assertTrue(
            get_checker(task1).task.is_assigned_to_current_admin_unit)
        self.assertFalse(
            get_checker(task2).task.is_assigned_to_current_admin_unit)
Пример #24
0
    def test_is_assigned_to_current_admin_unit(self):
        admin_unit = create(Builder('admin_unit')
                            .id('additional'))
        create(Builder('org_unit')
               .id('additional')
               .with_default_groups()
               .having(title='Additional',
                       admin_unit=admin_unit))

        task1 = create(Builder('forwarding')
                       .having(responsible_client='client1'))
        task2 = create(Builder('forwarding')
                       .having(responsible=TEST_USER_ID,
                               issuer=TEST_USER_ID,
                               responsible_client='additional'))

        self.assertTrue(get_checker(task1).task.is_assigned_to_current_admin_unit)
        self.assertFalse(get_checker(task2).task.is_assigned_to_current_admin_unit)
    def test_all_subtasks_finished(self):
        task = create(Builder('task').in_state('task-state-in-progress'))
        create(
            Builder('task').within(task).in_state(
                'task-state-tested-and-closed'))
        create(Builder('task').within(task).in_state('task-state-rejected'))
        create(Builder('task').within(task).in_state('task-state-cancelled'))

        self.assertTrue(get_checker(task).task.all_subtasks_finished)
Пример #26
0
    def test_all_subtasks_is_NOT_finished_when_cancelled_or_resolved(self):
        task = create(Builder('task').in_state('task-state-in-progress'))
        create(Builder('task')
               .within(task)
               .in_state('task-state-resolved'))
        create(Builder('task')
               .within(task)
               .in_state('task-state-cancelled'))

        self.assertFalse(get_checker(task).task.all_subtasks_finished)
Пример #27
0
 def test_issuing_orgunit_agency_member(self):
     """Checks if the current user is member of the issuing
     orgunit's inbox_group"""
     self.login(self.secretariat_user)
     self.assertTrue(
         get_checker(
             self.task).current_user.in_issuing_orgunits_inbox_group)
     checker = Checker(self.task.get_sql_object(), self.request,
                       self.secretariat_user)
     self.assertFalse(checker.current_user.in_issuing_orgunits_inbox_group)
Пример #28
0
    def test_issuing_orgunit_agency_member(self):
        """Checks if the current user is member of the issuing
        orgunit's inbox_group"""

        task1 = create(Builder('task').having(issuer=TEST_USER_ID))

        self.assertTrue(
            get_checker(task1).current_user.in_issuing_orgunits_inbox_group)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(checker.current_user.in_issuing_orgunits_inbox_group)
    def test_issuing_orgunit_agency_member(self):
        """Checks if the current user is member of the issuing
        orgunit's inbox_group"""

        task1 = create(Builder('task').having(issuer=TEST_USER_ID))

        self.assertTrue(
            get_checker(task1).current_user.in_issuing_orgunits_inbox_group)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(checker.current_user.in_issuing_orgunits_inbox_group)
Пример #30
0
    def test_responsible_orgunit_agency_member(self):
        """Checks if the current user is member of the responsible
        orgunit's inbox_group"""
        self.login(self.secretariat_user)
        self.assertTrue(
            get_checker(self.task).current_user.in_responsible_orgunits_inbox_group)

        # test as well without agency
        checker = Checker(self.task.get_sql_object(), self.request, self.secretariat_user)
        self.assertFalse(
            checker.current_user.in_responsible_orgunits_inbox_group)
Пример #31
0
    def test_responsible_orgunit_agency_member(self):
        """Checks if the current user is member of the responsible
        orgunit's inbox_group"""

        task1 = create(Builder('task').having(responsible_client='client1'))

        self.assertTrue(
            get_checker(task1).current_user.in_responsible_orgunits_inbox_group)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(
            checker.current_user.in_responsible_orgunits_inbox_group)
Пример #32
0
    def test_all_subtasks_finished(self):
        task = create(Builder('task').in_state('task-state-in-progress'))
        create(Builder('task')
               .within(task)
               .in_state('task-state-tested-and-closed'))
        create(Builder('task')
               .within(task)
               .in_state('task-state-rejected'))
        create(Builder('task')
               .within(task)
               .in_state('task-state-cancelled'))

        self.assertTrue(get_checker(task).task.all_subtasks_finished)
    def test_responsible_orgunit_agency_member(self):
        """Checks if the current user is member of the responsible
        orgunit's inbox_group"""

        task1 = create(Builder('task').having(responsible_client='client1'))

        self.assertTrue(
            get_checker(
                task1).current_user.in_responsible_orgunits_inbox_group)

        checker = Checker(task1.get_sql_object(), self.request, self.hugo)
        self.assertFalse(
            checker.current_user.in_responsible_orgunits_inbox_group)
Пример #34
0
    def test_responsible_orgunit_agency_member(self):
        """Checks if the current user is member of the responsible
        orgunit's inbox_group"""
        self.login(self.secretariat_user)
        self.assertTrue(
            get_checker(
                self.task).current_user.in_responsible_orgunits_inbox_group)

        # test as well without agency
        checker = Checker(self.task.get_sql_object(), self.request,
                          self.secretariat_user)
        self.assertFalse(
            checker.current_user.in_responsible_orgunits_inbox_group)
Пример #35
0
    def is_modify_allowed(self, include_agency=True):
        """Check if the current user is allowed to modify the deadline:
        - state is `in-progress` or `open`
        - and is issuer or agency member (adminstrator or issuing
        orgunit agency member).
        """
        # TODO: should be solved by a own permission 'modify_deadline'
        # but right now the issuer has not a sperate role.

        if not self.context.is_editable:
            return False

        checker = get_checker(self.context)
        if not include_agency:
            return checker.current_user.is_issuer
        else:
            return (checker.current_user.is_issuer
                    or checker.current_user.in_issuing_orgunits_inbox_group
                    or checker.current_user.is_administrator)
Пример #36
0
    def is_modify_allowed(self, include_agency=True):
        """Check if the current user is allowed to modify the deadline:
        - state is `in-progress` or `open`
        - and is issuer or agency member (adminstrator or issuing
        orgunit agency member).
        """
        # TODO: should be solved by a own permission 'modify_deadline'
        # but right now the issuer has not a sperate role.

        if not self.context.is_editable:
            return False

        checker = get_checker(self.context)
        if not include_agency:
            return checker.current_user.is_issuer
        else:
            return (checker.current_user.is_issuer or
                    checker.current_user.in_issuing_orgunits_inbox_group or
                    checker.current_user.is_administrator)
    def test_all_subtasks_is_NOT_finished_when_cancelled_or_resolved(self):
        task = create(Builder('task').in_state('task-state-in-progress'))
        create(Builder('task').within(task).in_state('task-state-resolved'))
        create(Builder('task').within(task).in_state('task-state-cancelled'))

        self.assertFalse(get_checker(task).task.all_subtasks_finished)
    def test_is_responsible(self):
        task1 = create(Builder('task').having(responsible=TEST_USER_ID))
        task2 = create(Builder('task').having(responsible='hugo.boss'))

        self.assertTrue(get_checker(task1).current_user.is_responsible)
        self.assertFalse(get_checker(task2).current_user.is_responsible)
    def test_is_issuer(self):
        task1 = create(Builder('task').having(issuer=TEST_USER_ID))
        task2 = create(Builder('task').having(issuer='hugo.boss'))

        self.assertTrue(get_checker(task1).current_user.is_issuer)
        self.assertFalse(get_checker(task2).current_user.is_issuer)
Пример #40
0
    def test_is_issuer(self):
        task1 = create(Builder('task').having(issuer=TEST_USER_ID))
        task2 = create(Builder('task').having(issuer='hugo.boss'))

        self.assertTrue(get_checker(task1).current_user.is_issuer)
        self.assertFalse(get_checker(task2).current_user.is_issuer)
Пример #41
0
 def test_is_remote_request_checks_ogds_plugin_flag(self):
     self.login(self.regular_user)
     self.assertFalse(get_checker(self.task).request.is_remote)
     self.task.REQUEST.environ['X_OGDS_AUID'] = 'rr'
     self.assertTrue(get_checker(self.task).request.is_remote)
Пример #42
0
 def test_is_successor_process_checks_request_for_succesor_flag(self):
     self.login(self.regular_user)
     self.assertFalse(get_checker(self.task).request.is_successor_process)
     self.task.REQUEST.set('X-CREATING-SUCCESSOR', True)
     self.assertTrue(get_checker(self.task).request.is_successor_process)
Пример #43
0
    def test_is_responsible(self):
        task1 = create(Builder('task').having(responsible=TEST_USER_ID))
        task2 = create(Builder('task').having(responsible='hugo.boss'))

        self.assertTrue(get_checker(task1).current_user.is_responsible)
        self.assertFalse(get_checker(task2).current_user.is_responsible)
Пример #44
0
 def test_is_successor_process_checks_request_for_succesor_flag(self):
     self.login(self.regular_user)
     self.assertFalse(get_checker(self.task).request.is_successor_process)
     self.task.REQUEST.set('X-CREATING-SUCCESSOR', True)
     self.assertTrue(get_checker(self.task).request.is_successor_process)
Пример #45
0
 def test_is_remote_request_checks_ogds_plugin_flag(self):
     self.login(self.regular_user)
     self.assertFalse(get_checker(self.task).request.is_remote)
     self.task.REQUEST.environ['X_OGDS_AUID'] = 'rr'
     self.assertTrue(get_checker(self.task).request.is_remote)
Пример #46
0
    def test_has_successors(self):
        self.login(self.dossier_responsible)
        self.register_successor(self.task, self.subtask)

        self.assertTrue(get_checker(self.task).task.has_successors)
        self.assertFalse(get_checker(self.subtask).task.has_successors)
Пример #47
0
 def test_all_subtasks_finished_is_allways_true_when_no_subtask_exists(self):
     self.login(self.dossier_responsible)
     self.assertTrue(get_checker(self.expired_task).task.all_subtasks_finished)
Пример #48
0
    def test_has_successors(self):
        self.login(self.dossier_responsible)
        self.register_successor(self.task, self.subtask)

        self.assertTrue(get_checker(self.task).task.has_successors)
        self.assertFalse(get_checker(self.subtask).task.has_successors)
Пример #49
0
 def test_all_subtasks_finished_is_allways_true_when_no_subtask_exists(
         self):
     self.login(self.dossier_responsible)
     self.assertTrue(
         get_checker(self.archive_task).task.all_subtasks_finished)
Пример #50
0
 def test_all_subtasks_finished(self):
     self.login(self.dossier_responsible)
     for state in ('task-state-rejected', 'task-state-cancelled',
                   'task-state-tested-and-closed'):
         self.set_workflow_state(state, self.subtask)
         self.assertTrue(get_checker(self.task).task.all_subtasks_finished)
    def test_all_subtasks_finished_is_allways_true_when_no_subtask_exists(
            self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertTrue(get_checker(task).task.all_subtasks_finished)
Пример #52
0
    def test_all_subtasks_finished_is_allways_true_when_no_subtask_exists(self):
        task = create(Builder('task').in_state('task-state-in-progress'))

        self.assertTrue(get_checker(task).task.all_subtasks_finished)