def test_shutdown_worker_raise_if_authenticated_but_not_admin(self): with self.assertRaises(PermissionDenied): client.shutdown_worker( _make_request( is_authenticated=False, is_superuser=False, ), 'worker')
def test_shutdown_worker_kill(self): w = Worker.objects.create( worker_key='enabled-worker', name='enabled-worker', enabled=True, ) task_id = client.shutdown_worker(_make_request(), w.name, kill=True) self.assertTrue(task_id > 0) task = Task.objects.get(id=task_id) self.assertTrue(task.exclusive) self.assertTrue('kill' in task.args) self.assertTrue(task.args['kill']) self.assertEqual(task.method, 'ShutdownWorker')
def test_shutdown_worker_raise_if_authenticated_but_not_admin(self): with self.assertRaises(PermissionDenied): client.shutdown_worker(_make_request( is_authenticated=False, is_superuser=False, ), 'worker')