def test_set_task_weight_fails_if_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['OPEN'], ) self.assertEqual(t.weight, 1) req = _make_request(self._worker) with self.assertRaises(Task.DoesNotExist): worker.set_task_weight(req, t.id, 100) t = Task.objects.get(id=t.id) self.assertEqual(t.weight, 1)
def test_set_task_weight_fails_if_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['OPEN'], ) self.assertEqual(t.weight, 1) req = _make_request(self._worker) with self.assertRaises(Task.DoesNotExist): worker.set_task_weight(req, t.id, 100) t = Task.objects.get(id=t.id) self.assertEqual(t.weight, 1)
def test_set_task_weight(self): t = Task.objects.create( worker=self._worker, arch=self._arch, channel=self._channel, owner=self._user, state=TASK_STATES['OPEN'], ) self.assertEqual(t.weight, 1) req = _make_request(self._worker) weight = worker.set_task_weight(req, t.id, 100) self.assertEqual(weight, 100) t = Task.objects.get(id=t.id) self.assertEqual(t.weight, 100)
def test_set_task_weight(self): t = Task.objects.create( worker=self._worker, arch=self._arch, channel=self._channel, owner=self._user, state=TASK_STATES['OPEN'], ) self.assertEqual(t.weight, 1) req = _make_request(self._worker) weight = worker.set_task_weight(req, t.id, 100) self.assertEqual(weight, 100) t = Task.objects.get(id=t.id) self.assertEqual(t.weight, 100)
def set_task_weight(self, task_id, weight): return worker.set_task_weight(self._request, task_id, weight)
def test_set_task_weight(self): with self.assertRaises(PermissionDenied): worker.set_task_weight(_make_request(None, False), 1, 10)
def test_set_task_weight(self): with self.assertRaises(PermissionDenied): worker.set_task_weight(_make_request(None, False), 1, 10)