Exemplo n.º 1
0
    def test_get_tasks_with_no_filters(self):
        Task.create_task(self._user.username, 'task-1', 'method')
        Task.create_task(self._user.username, 'task-2', 'method')
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), None, None)

        self.assertEqual(len(task_list), 5)
    def test_get_tasks_with_no_filters(self):
        Task.create_task(self._user.username, 'task-1', 'method')
        Task.create_task(self._user.username, 'task-2', 'method')
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), None, None)

        self.assertEqual(len(task_list), 5)
Exemplo n.º 3
0
    def test_cancel_task(self):
        task_id = Task.create_task(self._user.username, 'task', 'method')
        ret = client.cancel_task(_make_request(), task_id)
        self.assertIsNone(ret)

        t = Task.objects.get(id=task_id)
        self.assertEqual(t.state, TASK_STATES['CANCELED'])
Exemplo n.º 4
0
 def test_resubmit_task(self):
     task_id = Task.create_task(self._user.username, 'task', 'method', state=TASK_STATES['TIMEOUT'])
     new_id = client.resubmit_task(_make_request(self._user), task_id, force=False)
     self.assertTrue(new_id > 0)
     self.assertNotEqual(task_id, new_id)
     task = Task.objects.get(id=new_id)
     self.assertEqual(task.priority, 10)
    def test_cancel_task(self):
        task_id = Task.create_task(self._user.username, 'task', 'method')
        ret = client.cancel_task(_make_request(), task_id)
        self.assertIsNone(ret)

        t = Task.objects.get(id=task_id)
        self.assertEqual(t.state, TASK_STATES['CANCELED'])
Exemplo n.º 6
0
    def test_resubmit_task_do_not_failed(self):
        task_id = Task.create_task(self._user.username,
                                   'task',
                                   'method',
                                   state=TASK_STATES['OPEN'])

        with self.assertRaises(Exception):
            client.resubmit_task(_make_request(), task_id, force=False)
Exemplo n.º 7
0
    def test_get_tasks_filter_by_ids(self):
        t1 = Task.create_task(self._user.username, 'task-1', 'method')
        t2 = Task.create_task(self._user.username, 'task-2', 'method')
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), [t1, t2], None)

        self.assertEqual(len(task_list), 2)
        self.assertEqual(set([t['id'] for t in task_list]), set([t1, t2]))
Exemplo n.º 8
0
    def test_get_tasks_filter_by_state(self):
        t1 = Task.create_task(self._user.username, 'task-1', 'method', state=TASK_STATES['OPEN'])
        t2 = Task.create_task(self._user.username, 'task-2', 'method', state=TASK_STATES['TIMEOUT'])
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), None, [TASK_STATES['OPEN'], TASK_STATES['TIMEOUT']])

        self.assertEqual(len(task_list), 2)
        self.assertEqual(set([t['id'] for t in task_list]), set([t1, t2]))
    def test_get_tasks_filter_by_state(self):
        t1 = Task.create_task(self._user.username, 'task-1', 'method', state=TASK_STATES['OPEN'])
        t2 = Task.create_task(self._user.username, 'task-2', 'method', state=TASK_STATES['TIMEOUT'])
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), None, [TASK_STATES['OPEN'], TASK_STATES['TIMEOUT']])

        self.assertEqual(len(task_list), 2)
        self.assertEqual(set([t['id'] for t in task_list]), set([t1, t2]))
Exemplo n.º 10
0
    def test_get_tasks_filter_by_ids(self):
        t1 = Task.create_task(self._user.username, 'task-1', 'method')
        t2 = Task.create_task(self._user.username, 'task-2', 'method')
        Task.create_task(self._user.username, 'task-3', 'method')
        Task.create_task(self._user.username, 'task-4', 'method')
        Task.create_task(self._user.username, 'task-5', 'method')

        task_list = client.get_tasks(_make_request(), [t1, t2], None)

        self.assertEqual(len(task_list), 2)
        self.assertEqual(set([t['id'] for t in task_list]), set([t1, t2]))
Exemplo n.º 11
0
 def test_resubmit_task_force_not_failed(self):
     task_id = Task.create_task(self._user.username,
                                'task',
                                'method',
                                state=TASK_STATES['OPEN'])
     new_id = client.resubmit_task(_make_request(self._user),
                                   task_id,
                                   force=True)
     self.assertTrue(new_id > 0)
     self.assertNotEqual(task_id, new_id)
Exemplo n.º 12
0
def create_subtask(request, label, method, args, parent_id):
    parent_task = Task.objects.get_and_verify(task_id=parent_id, worker=request.worker)

    return Task.create_task(
        parent_task.owner.username,
        label,
        method,
        args=args,
        parent_id=parent_id,
        arch_name=parent_task.arch.name,
        channel_name=parent_task.channel.name,
    )
Exemplo n.º 13
0
def create_subtask(request, label, method, args, parent_id):
    parent_task = Task.objects.get_and_verify(task_id=parent_id,
                                              worker=request.worker)

    return Task.create_task(
        parent_task.owner.username,
        label,
        method,
        args=args,
        parent_id=parent_id,
        arch_name=parent_task.arch.name,
        channel_name=parent_task.channel.name,
    )
Exemplo n.º 14
0
    def test_create_task_based_on_task(self):
        base_task_id = Task.create_task(self._user.username, 'task', 'method')

        clone_task_id = client.create_task(_make_request(self._user), {
            'task_id': base_task_id,
        })

        self.assertTrue(clone_task_id > 0)
        self.assertNotEqual(base_task_id, clone_task_id)

        task = Task.objects.get(id=clone_task_id)
        self.assertEqual(task.resubmitted_by.id, self._user.id)
        self.assertEqual(task.resubmitted_from.id, base_task_id)
Exemplo n.º 15
0
def create_subtask(request, label, method, args, parent_id):
    parent_task = Task.objects.get_and_verify(task_id=parent_id,
                                              worker=request.worker)
    #    def create_task(cls, owner_name, label, method, args=None, parent_id=None, worker_name=None, arch_name="noarch", channel_name="default", priority=10, weight=1, exclusive=False):
    #    subtask_id = self.__hub.worker.createSubtask(label, method, args, self.__task_id)
    return Task.create_task(parent_task.owner.username,
                            label,
                            method,
                            args=args,
                            parent_id=parent_id,
                            arch_name=parent_task.arch.name,
                            channel_name=parent_task.channel.name
                            )  # priority=priority, weight=weight)
Exemplo n.º 16
0
    def test_create_task_based_on_task(self):
        base_task_id = Task.create_task(self._user.username, 'task', 'method')

        clone_task_id = client.create_task(_make_request(self._user), {
            'task_id': base_task_id,
        })

        self.assertTrue(clone_task_id > 0)
        self.assertNotEqual(base_task_id, clone_task_id)

        task = Task.objects.get(id=clone_task_id)
        self.assertEqual(task.resubmitted_by.id, self._user.id)
        self.assertEqual(task.resubmitted_from.id, base_task_id)
Exemplo n.º 17
0
 def test_task_info_flat(self):
     task_id = Task.create_task(self._user.username, 'label', 'method')
     task_info = client.task_info(_make_request(), task_id, flat=True)
     self.assertEqual(task_info['id'], task_id)
Exemplo n.º 18
0
    def test_resubmit_task_do_not_failed(self):
        task_id = Task.create_task(self._user.username, 'task', 'method', state=TASK_STATES['OPEN'])

        with self.assertRaises(Exception):
            client.resubmit_task(_make_request(), task_id, force=False)
Exemplo n.º 19
0
 def test_resubmit_task_force_not_failed(self):
     task_id = Task.create_task(self._user.username, 'task', 'method', state=TASK_STATES['OPEN'])
     new_id = client.resubmit_task(_make_request(self._user), task_id, force=True)
     self.assertTrue(new_id > 0)
     self.assertNotEqual(task_id, new_id)
Exemplo n.º 20
0
def create_subtask(request, label, method, args, parent_id):
    parent_task = Task.objects.get_and_verify(task_id=parent_id, worker=request.worker)
#    def create_task(cls, owner_name, label, method, args=None, parent_id=None, worker_name=None, arch_name="noarch", channel_name="default", priority=10, weight=1, exclusive=False):
#    subtask_id = self.__hub.worker.createSubtask(label, method, args, self.__task_id)
    return Task.create_task(parent_task.owner.username, label, method, args=args, parent_id=parent_id, arch_name=parent_task.arch.name, channel_name=parent_task.channel.name)# priority=priority, weight=weight)
Exemplo n.º 21
0
 def test_task_info_flat(self):
     task_id = Task.create_task(self._user.username, 'label', 'method')
     task_info = client.task_info(_make_request(), task_id, flat=True)
     self.assertEqual(task_info['id'], task_id)