Exemplo n.º 1
0
    def test_can_get_content_with_id(self):
        # pass content_id
        root_id = content.ContentMetadata.objects.using(self.the_channel_id).get(title="root").content_id
        expected_output = content.ContentMetadata.objects.using(self.the_channel_id).filter(title__in=["c1", "c2"])
        actual_output = api.immediate_children(channel_id=self.the_channel_id, content=str(root_id))
        self.assertEqual(set(expected_output), set(actual_output))

        # pass content_ids
        api.set_is_related(channel_id=self.the_channel_id, content1=str(expected_output[0].content_id), content2=str(root_id))

        # pass invalid type
        with self.assertRaises(TypeError):
            api.immediate_children(channel_id=self.the_channel_id, content=432)
Exemplo n.º 2
0
    def test_can_get_content_with_id(self):
        # pass content_id
        root_id = content.ContentMetadata.objects.using(self.the_channel_id).get(title="root").content_id
        expected_output = content.ContentMetadata.objects.using(self.the_channel_id).filter(title__in=["c1", "c2"])
        actual_output = api.immediate_children(channel_id=self.the_channel_id, content=str(root_id))
        self.assertEqual(set(expected_output), set(actual_output))

        # pass content_ids
        api.set_is_related(channel_id=self.the_channel_id, content1=str(expected_output[0].content_id), content2=str(root_id))

        # pass invalid type
        with self.assertRaises(TypeError):
            api.immediate_children(channel_id=self.the_channel_id, content=432)
Exemplo n.º 3
0
 def test_immediate_children(self):
     p = content.ContentMetadata.objects.using(
         self.the_channel_id).get(title="root")
     expected_output = content.ContentMetadata.objects.using(
         self.the_channel_id).filter(title__in=["c1", "c2"])
     actual_output = api.immediate_children(channel_id=self.the_channel_id,
                                            content=p)
     self.assertEqual(set(expected_output), set(actual_output))
Exemplo n.º 4
0
 def immediate_children(self, request, channelmetadata_channel_id, *args, **kwargs):
     """
     endpoint for content api method
     immediate_children(channel_id=None, content=None, **kwargs)
     """
     context = {'request': request, 'channel_id': channelmetadata_channel_id}
     data = serializers.ContentMetadataSerializer(
         api.immediate_children(channel_id=channelmetadata_channel_id, content=self.kwargs['content_id']), context=context, many=True
     ).data
     return Response(data)
Exemplo n.º 5
0
 def test_immediate_children(self):
     p = content.ContentMetadata.objects.using(self.the_channel_id).get(title="root")
     expected_output = content.ContentMetadata.objects.using(self.the_channel_id).filter(title__in=["c1", "c2"])
     actual_output = api.immediate_children(channel_id=self.the_channel_id, content=p)
     self.assertEqual(set(expected_output), set(actual_output))