Пример #1
0
 def test_get_possible_formats(self):
     p = content.ContentMetadata.objects.using(
         self.the_channel_id).get(title="c1")
     expected_output = content.Format.objects.using(
         self.the_channel_id).filter(format_size__in=[51, 102])
     actual_output = api.get_possible_formats(
         channel_id=self.the_channel_id, content=p)
     self.assertEqual(set(expected_output), set(actual_output))
Пример #2
0
 def possible_formats(self, request, channelmetadata_channel_id, *args, **kwargs):
     """
     endpoint for content api method
     get_possible_formats(channel_id=None, content=None, **kwargs)
     """
     context = {'request': request, 'channel_id': channelmetadata_channel_id}
     data = serializers.FormatSerializer(
         api.get_possible_formats(channel_id=channelmetadata_channel_id, content=self.kwargs['content_id']), context=context, many=True
     ).data
     return Response(data)
Пример #3
0
 def test_get_possible_formats(self):
     p = content.ContentMetadata.objects.using(self.the_channel_id).get(title="c1")
     expected_output = content.Format.objects.using(self.the_channel_id).filter(format_size__in=[51, 102])
     actual_output = api.get_possible_formats(channel_id=self.the_channel_id, content=p)
     self.assertEqual(set(expected_output), set(actual_output))