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)
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)
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))
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)
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))