Example #1
0
    def test_get_youtube_thumb(self):
        video = VideoFileFactory.create(**{'youtube_id': '14emk_jPnrI'})

        serializer = FileSerializer(video, context={'user': video.creator})

        self.assertNotEqual(serializer.get_thumbnail_url(video),
                            '/static/img/play.png')
Example #2
0
    def test_get_youtube_no_thumb(self):
        video = VideoFileFactory.create(**{'youtube_id': 'asadf'})

        serializer = FileSerializer(video, context={'user': video.creator})
        self.assertEqual(
            serializer.get_thumbnail_url(video),
            '/static/img/play.png'
        )
Example #3
0
    def test_get_thumb_url(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertEqual(
            serializer.get_thumbnail_url(image),
            image.image.url + '.300x300_q85_crop.png'
        )
Example #4
0
    def test_get_is_owner(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertTrue(serializer.get_is_owner(image))

        serializer = FileSerializer(image, context={'user': UserF.create()})
        self.assertFalse(serializer.get_is_owner(image))

        serializer = FileSerializer(image, context={'user': AnonymousUser()})
        self.assertFalse(serializer.get_is_owner(image))
Example #5
0
    def test_get_is_owner(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertTrue(serializer.get_is_owner(image))

        serializer = FileSerializer(image, context={'user': UserF.create()})
        self.assertFalse(serializer.get_is_owner(image))

        serializer = FileSerializer(image, context={'user': AnonymousUser()})
        self.assertFalse(serializer.get_is_owner(image))
Example #6
0
    def test_get_video_file_type(self):
        video = VideoFileFactory.create()

        serializer = FileSerializer(video, context={'user': video.creator})
        self.assertEqual(serializer.get_type(video), 'VideoFile')
Example #7
0
    def test_get_youtube_link(self):
        video = VideoFileFactory.create()

        serializer = FileSerializer(video, context={'user': video.creator})
        self.assertEqual(serializer.get_url(video), video.youtube_link)
Example #8
0
    def test_get_thumb_url(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertEqual(serializer.get_thumbnail_url(image),
                         image.image.url + '.300x300_q85_crop.png')
Example #9
0
    def test_get_image_url(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertEqual(serializer.get_url(image), image.image.url)
Example #10
0
    def test_get_video_file_type(self):
        video = VideoFileFactory.create()

        serializer = FileSerializer(video, context={'user': video.creator})
        self.assertEqual(serializer.get_type(video), 'VideoFile')
Example #11
0
    def test_get_youtube_link(self):
        video = VideoFileFactory.create()

        serializer = FileSerializer(video, context={'user': video.creator})
        self.assertEqual(serializer.get_url(video), video.youtube_link)
Example #12
0
    def test_get_image_url(self):
        image = ImageFileFactory.create()

        serializer = FileSerializer(image, context={'user': image.creator})
        self.assertEqual(serializer.get_url(image), image.image.url)