Ejemplo n.º 1
0
    def test_assign_task(self):
        t = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['FREE'],
        )

        req = _make_request(self._worker)
        worker.assign_task(req, t.id)

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['ASSIGNED'])
Ejemplo n.º 2
0
    def test_assign_task(self):
        t = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['FREE'],
        )

        req = _make_request(self._worker)
        worker.assign_task(req, t.id)

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['ASSIGNED'])
Ejemplo n.º 3
0
    def test_assign_task_fails_to_assing_another_worker_task(self):
        w = Worker.objects.create(
            worker_key='other-worker',
            name='other-worker',
        )

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

        req = _make_request(self._worker)

        with self.assertRaises(Exception):
            worker.assign_task(req, t.id)

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['FREE'])
Ejemplo n.º 4
0
    def test_assign_task_fails_to_assing_another_worker_task(self):
        w = Worker.objects.create(
            worker_key='other-worker',
            name='other-worker',
        )

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

        req = _make_request(self._worker)

        with self.assertRaises(Exception):
            worker.assign_task(req, t.id)

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['FREE'])
Ejemplo n.º 5
0
 def assign_task(self, task_id):
     return worker.assign_task(self._request, task_id)
Ejemplo n.º 6
0
 def test_assign_task(self):
     with self.assertRaises(PermissionDenied):
         worker.assign_task(_make_request(None, False), 1)
Ejemplo n.º 7
0
 def test_assign_task(self):
     with self.assertRaises(PermissionDenied):
         worker.assign_task(_make_request(None, False), 1)