def test_get_task_cant_get_task_from_other_worker(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(Task.DoesNotExist): worker.get_task(req, t.id)
def test_get_task_cant_get_task_from_other_worker(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(Task.DoesNotExist): worker.get_task(req, t.id)
def test_get_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) task_info = worker.get_task(req, t.id) self.assertEqual(task_info['id'], t.id) self.assertEqual(task_info['worker'], self._worker.id) self.assertEqual(task_info['state'], t.state)
def test_get_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) task_info = worker.get_task(req, t.id) self.assertEqual(task_info['id'], t.id) self.assertEqual(task_info['worker'], self._worker.id) self.assertEqual(task_info['state'], t.state)
def get_task(self, task_id): return worker.get_task(self._request, task_id)
def test_get_task(self): with self.assertRaises(PermissionDenied): worker.get_task(_make_request(None, False), 1)
def test_get_task(self): with self.assertRaises(PermissionDenied): worker.get_task(_make_request(None, False), 1)