Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
    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')
Ejemplo n.º 3
0
    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')
Ejemplo n.º 4
0
 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')