Example #1
0
    def test_open_task(self):
        t = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['ASSIGNED'],
        )

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

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['OPEN'])
    def test_open_task(self):
        t = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['ASSIGNED'],
        )

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

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['OPEN'])
Example #3
0
    def test_open_task_fails_to_open_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['ASSIGNED'],
        )

        req = _make_request(self._worker)

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

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['ASSIGNED'])
    def test_open_task_fails_to_open_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['ASSIGNED'],
        )

        req = _make_request(self._worker)

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

        t = Task.objects.get(id=t.id)
        self.assertEqual(t.state, TASK_STATES['ASSIGNED'])
Example #5
0
 def open_task(self, task_id):
     return worker.open_task(self._request, task_id)
Example #6
0
 def test_open_task(self):
     with self.assertRaises(PermissionDenied):
         worker.open_task(_make_request(None, False), 1)
 def test_open_task(self):
     with self.assertRaises(PermissionDenied):
         worker.open_task(_make_request(None, False), 1)