Beispiel #1
0
    def test_task_runner_get(self):
        from autotasks.serializers import TaskGOGetSerializer

        r = self.client.get("/api/v3/500/asdf9df9dfdf/taskrunner/")
        self.assertEqual(r.status_code, 404)

        # setup data
        agent = baker.make_recipe("agents.agent")
        task = baker.make("autotasks.AutomatedTask", agent=agent)

        url = f"/api/v3/{task.pk}/{agent.agent_id}/taskrunner/"  # type: ignore

        r = self.client.get(url)
        self.assertEqual(r.status_code, 200)
        self.assertEqual(TaskGOGetSerializer(task).data,
                         r.data)  # type: ignore
Beispiel #2
0
 def get(self, request, pk, agentid):
     agent = get_object_or_404(Agent, agent_id=agentid)
     task = get_object_or_404(AutomatedTask, pk=pk)
     return Response(TaskGOGetSerializer(task).data)