def test_get_tasks_to_assign_limit_tasks(self):
        for _ in range(10):
            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES['FREE'],
            )

            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES['ASSIGNED'],
                exclusive=True,
            )

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

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

        self.assertEqual(len(tasks), 10)
        self.assertEqual(len([t for t in tasks if t['state'] == TASK_STATES['ASSIGNED'] and t['exclusive']]), 10)
Beispiel #2
0
    def test_get_tasks_to_assign_limit_tasks(self):
        for _ in range(10):
            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES['FREE'],
            )

            Task.objects.create(
                worker=self._worker,
                arch=self._arch,
                channel=self._channel,
                owner=self._user,
                state=TASK_STATES['ASSIGNED'],
                exclusive=True,
            )

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

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

        self.assertEqual(len(tasks), 10)
        self.assertEqual(len([t for t in tasks if t['state'] == TASK_STATES['ASSIGNED'] and t['exclusive']]), 10)
Beispiel #3
0
 def get_tasks_to_assign(self):
     return worker.get_tasks_to_assign(self._request, )
Beispiel #4
0
 def test_get_tasks_to_assign(self):
     with self.assertRaises(PermissionDenied):
         worker.get_tasks_to_assign(_make_request(None, False))
 def test_get_tasks_to_assign(self):
     with self.assertRaises(PermissionDenied):
         worker.get_tasks_to_assign(_make_request(None, False))