示例#1
0
    def test_get_worker_tasks_check_wait(self):
        t_parent = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['OPEN'],
            waiting=True,
        )

        Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['CLOSED'],
            parent=t_parent,
            awaited=True,
        )

        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(len(tasks), 1)
        self.assertEqual(tasks[0]['id'], t_parent.id)
        self.assertTrue(tasks[0]['alert'])
    def test_get_worker_tasks_check_wait(self):
        t_parent = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['OPEN'],
            waiting=True,
        )

        Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['CLOSED'],
            parent=t_parent,
            awaited=True,
        )

        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(len(tasks), 1)
        self.assertEqual(tasks[0]['id'], t_parent.id)
        self.assertTrue(tasks[0]['alert'])
示例#3
0
    def test_get_worker_tasks(self):
        for state in TASK_STATES:
            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES[state],
            )

        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(len(tasks), 2)
        self.assertTrue(tasks[0]['id'] < tasks[1]['id'])

        for task in tasks:
            self.assertTrue(task['state'] in [TASK_STATES['ASSIGNED'], TASK_STATES['OPEN']])
    def test_get_worker_tasks(self):
        for state in TASK_STATES:
            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES[state],
            )

        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(len(tasks), 2)
        self.assertTrue(tasks[0]['id'] < tasks[1]['id'])

        for task in tasks:
            self.assertTrue(task['state'] in [TASK_STATES['ASSIGNED'], TASK_STATES['OPEN']])
示例#5
0
 def get_worker_tasks(self):
     return worker.get_worker_tasks(self._request)
示例#6
0
    def test_get_worker_tasks_returns_empty_list_if_no_tasks(self):
        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(tasks, [])
示例#7
0
 def test_get_worker_tasks(self):
     with self.assertRaises(PermissionDenied):
         worker.get_worker_tasks(_make_request(None, False))
    def test_get_worker_tasks_returns_empty_list_if_no_tasks(self):
        req = _make_request(self._worker)
        tasks = worker.get_worker_tasks(req)

        self.assertEqual(tasks, [])
 def test_get_worker_tasks(self):
     with self.assertRaises(PermissionDenied):
         worker.get_worker_tasks(_make_request(None, False))