How to use the kobo.hub.models.Task.create_task function in kobo

To help you get started, we’ve selected a few kobo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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]))
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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)
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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]))
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
def test_task_info(self):
        task_id = Task.create_task(self._user.username, 'label', 'method')
        task_info = client.task_info(_make_request(), task_id)
        self.assertEqual(task_info['id'], task_id)
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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)
github release-engineering / kobo / tests / test_models.py View on Github external
def test_create_task(self):
        parent = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            method='DummyTask',
            state=TASK_STATES['OPEN'],
        )

        task_id = Task.create_task(
            self._user.username, 'label', 'MethodName',
            args={'key': 'value'},
            parent_id=parent.id,
            worker_name=self._worker.name,
        )

        self.assertTrue(task_id > 0)

        task = Task.objects.get(id=task_id)
        self.assertEquals(task.owner.id, self._user.id)
        self.assertEquals(task.worker.id, self._worker.id)
        self.assertEquals(task.parent.id, parent.id)
        self.assertEquals(task.state, TASK_STATES['ASSIGNED'])
        self.assertEquals(task.label, 'label')
        self.assertEquals(task.method, 'MethodName')
        self.assertEquals(task.args['key'], 'value')
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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]))
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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)
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
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]))
github release-engineering / kobo / kobo / hub / xmlrpc / client.py View on Github external
worker_name, arch_name, channel_name, timeout, priority, weight, exclusive
                   when task_id is set, the task is used as a template for the new one
    @type kwargs: dict
    @return: task id
    @rtype: int
    """

    old_task_id = kwargs.pop("task_id", None)
    if old_task_id is not None:
        old_task = models.Task.objects.get(id=old_task_id)
        return old_task.clone_task(request.user, **kwargs)

    kwargs.setdefault("label", "")
    kwargs["resubmitted_by"] = request.user
    kwargs["resubmitted_from"] = None
    return models.Task.create_task(**kwargs)