コード例 #1
0
    def test_sync_related_tasks_performs_a_request_for_each_successor(self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "SYNC_TASK"
        mock_request = self._mock_dispatch_request(sender, 'OK')

        sender.sync_related_tasks('test-transition', u't\xe4st')

        self.assertEqual(
            2, len(mock_request.requests),
            "The syncer should have made two requests. One for each successor")

        self.assertItemsEqual([{
            'data': {
                'text': 't\xc3\xa4st',
                'transition': 'test-transition'
            },
            'path': u'task-2',
            'target_admin_unit_id': u'client1',
            'viewname': 'SYNC_TASK'
        }, {
            'data': {
                'text': 't\xc3\xa4st',
                'transition': 'test-transition'
            },
            'path': u'task-3',
            'target_admin_unit_id': u'client1',
            'viewname': 'SYNC_TASK'
        }], mock_request.requests)
コード例 #2
0
    def test_sync_related_task_performs_a_request_to_the_target_sync_view_name(
            self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "SYNC_TASK"
        mock_request = self._mock_dispatch_request(sender, 'OK')

        task = sender.get_related_tasks_to_sync()[0]
        sender.sync_related_task(task,
                                 'test-transition',
                                 u't\xe4st',
                                 firstname='james')

        self.assertItemsEqual([
            {
                'data': {
                    'text': 't\xc3\xa4st',
                    'transition': 'test-transition',
                    'firstname': 'james'
                },
                'path': u'task-2',
                'target_admin_unit_id': u'client1',
                'viewname': 'SYNC_TASK'
            },
        ], mock_request.requests)
コード例 #3
0
    def test_sync_related_tasks_performs_a_request_for_each_successor(self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "SYNC_TASK"
        mock_request = self._mock_dispatch_request(sender, 'OK')

        sender.sync_related_tasks('test-transition', u't\xe4st')

        self.assertEqual(
            2, len(mock_request.requests),
            "The syncer should have made two requests. One for each successor")

        self.assertItemsEqual(
            [
                {'data': {'text': 't\xc3\xa4st', 'transition': 'test-transition'},
                 'path': u'task-2',
                 'target_admin_unit_id': u'admin-unit-1',
                 'viewname': 'SYNC_TASK'},
                {'data': {'text': 't\xc3\xa4st', 'transition': 'test-transition'},
                 'path': u'task-3',
                 'target_admin_unit_id': u'admin-unit-1',
                 'viewname': 'SYNC_TASK'}
            ],
            mock_request.requests
        )
コード例 #4
0
    def test_sync_related_tasks_raises_an_exception_if_syncing_failed(self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "NOT_EXISTING_VIEW"

        self._mock_dispatch_request(sender, 'NOT_FOUND')

        with self.assertRaises(ResponseSyncerSenderException):
            sender.sync_related_tasks('', '')
コード例 #5
0
    def test_sync_related_tasks_raises_an_exception_if_syncing_failed(self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "NOT_EXISTING_VIEW"

        self._mock_dispatch_request(sender, 'NOT_FOUND')

        with self.assertRaises(ResponseSyncerSenderException):
            sender.sync_related_tasks('', '')
コード例 #6
0
    def test_sync_related_task_performs_a_request_to_the_target_sync_view_name(self):
        predecessor = create(Builder('task').in_state('task-state-resolved'))
        create(Builder('task').successor_from(predecessor))

        sender = BaseResponseSyncerSender(predecessor, self.request)
        sender.TARGET_SYNC_VIEW_NAME = "SYNC_TASK"
        mock_request = self._mock_dispatch_request(sender, 'OK')

        task = sender.get_related_tasks_to_sync()[0]
        sender.sync_related_task(task, 'test-transition', u't\xe4st', firstname='james')

        self.assertItemsEqual(
            [
                {'data': {'text': 't\xc3\xa4st',
                          'transition': 'test-transition',
                          'firstname': 'james'},
                 'path': u'task-2',
                 'target_admin_unit_id': u'admin-unit-1',
                 'viewname': 'SYNC_TASK'},
            ],
            mock_request.requests
        )