Ejemplo n.º 1
0
 def child_steps(self, request, pk=None):
     step = self.get_object()
     child_steps = step.child_steps.all()
     page = self.paginate_queryset(child_steps)
     if page is not None:
         serializers = ProcessStepSerializer(page,
                                             many=True,
                                             context={'request': request})
         return self.get_paginated_response(serializers.data)
     serializers = ProcessStepSerializer(child_steps,
                                         many=True,
                                         context={'request': request})
     return Response(serializers.data)
Ejemplo n.º 2
0
 def test_no_ip_connected(self):
     ProcessStep.objects.create(name="example.Foo")
     response = self.client.get(self.url)
     request = APIRequestFactory().get(self.url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     steps = ProcessStep.objects.all()
     serializer = ProcessStepSerializer(steps, many=True, context={'request': request})
     self.assertEqual(response.data, serializer.data)
Ejemplo n.º 3
0
    def test_user_in_organization(self):
        membership = GroupMember.objects.create(member=self.member, group=self.org)
        membership.roles.add(self.user_role)

        ProcessStep.objects.create(name="example.Foo", information_package=self.ip)
        response = self.client.get(self.url)
        request = APIRequestFactory().get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        steps = ProcessStep.objects.all()
        serializer = ProcessStepSerializer(steps, many=True, context={'request': request})
        self.assertEqual(len(response.data), len(serializer.data))
        self.assertEqual(response.data, serializer.data)
Ejemplo n.º 4
0
    def test_authenticated(self):
        # get API response
        self.client.force_authenticate(user=self.user)
        request = APIRequestFactory().get(self.url)
        response = self.client.get(self.url)

        # get data from DB
        steps = ProcessStep.objects.all()
        serializer = ProcessStepSerializer(steps, many=True, context={'request': request})

        self.assertEqual(response.data, serializer.data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)