How to use wagtailvideos - 10 common examples

To help you get started, we’ve selected a few wagtailvideos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_edit(self):
        response = self.post({
            'title': "Edited",
        })

        # Should redirect back to index
        self.assertRedirects(response, reverse('wagtailvideos:index'))

        # Check that the video was edited
        video = Video.objects.get(id=self.video.id)
        self.assertEqual(video.title, "Edited")
        self.assertEqual(self.video.file, video.file)
github neon-jungle / wagtailvideos / tests / test_template_tag.py View on Github external
def setUp(self):
        self.video = Video.objects.create(
            title="Test Video",
            file=create_test_video_file()
        )
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_add_too_long_filename(self):
        video_file = create_test_video_file()

        name = 'a_very_long_filename_' + ('x' * 100) + '.mp4'
        response = self.post({
            'title': "Test video",
            'file': SimpleUploadedFile(name, video_file.read(), "video/mp4"),
        })

        # Should be valid
        self.assertEqual(response.status_code, 302)
        video = Video.objects.get()

        self.assertEqual(len(video.file.name), Video._meta.get_field('file').max_length)
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def setUp(self):
        self.login()

        # Create an video for running tests on
        self.video = Video.objects.create(
            title="Test video",
            file=create_test_video_file(),
        )
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_add(self):
        video_file = create_test_video_file()
        title = "Test Video"
        response = self.post({
            'title': title,
            'file': SimpleUploadedFile('small.mp4', video_file.read(), "video/mp4"),
        })

        # Should redirect back to index
        self.assertRedirects(response, reverse('wagtailvideos:index'))

        # Check that the video was created
        videos = Video.objects.filter(title=title)
        self.assertEqual(videos.count(), 1)

        # Test that extra fields were populated from post_save signal
        video = videos.first()
        self.assertTrue(video.thumbnail)
        self.assertTrue(video.duration)
        self.assertTrue(video.file_size)

        # Test that it was placed in the root collection
        root_collection = Collection.get_first_root_node()
        self.assertEqual(video.collection, root_collection)
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_upload(self):
        response = self.client.post(reverse('wagtailvideos:chooser_upload'), {
            'title': "Test video",
            'file': SimpleUploadedFile('small.mp4', create_test_video_file().read(), "video/mp4"),
        })

        # Check response
        self.assertEqual(response.status_code, 200)

        # Check that the video was created
        videos = Video.objects.filter(title="Test video")
        self.assertEqual(videos.count(), 1)
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def setUp(self):
        self.login()

        self.video = Video.objects.create(
            title="Test video",
            file=create_test_video_file(),
        )
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_pagination_after_upload_form_error(self):
        for i in range(0, 20):
            Video.objects.create(
                title="Test video %d" % i,
                file=create_test_video_file(),
            )

        response = self.client.post(reverse('wagtailvideos:chooser_upload'), {
            'title': "Test video",
        })

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'wagtailvideos/chooser/chooser.html')

        # The re-rendered video chooser listing should be paginated
        self.assertContains(response, "Page 1 of ")
        self.assertEqual(12, len(response.context['videos']))
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_filter_by_tag(self):
        for i in range(0, 10):
            video = Video.objects.create(
                title="Test video %d is even better than the last one" % i,
                file=create_test_video_file(),
            )
            if i % 2 == 0:
                video.tags.add('even')

        response = self.get({'tag': "even"})
        self.assertEqual(response.status_code, 200)

        # Results should include videos tagged 'even'
        self.assertContains(response, "Test video 2 is even better")

        # Results should not include videos that just have 'even' in the title
        self.assertNotContains(response, "Test video 3 is even better")
github neon-jungle / wagtailvideos / tests / test_admin_views.py View on Github external
def test_add_no_ffmpeg(self, ffmpeg_installed):
        ffmpeg_installed.return_value = False

        video_file = create_test_video_file()
        title = 'no_ffmpeg'

        response = self.post({
            'title': title,
            'file': SimpleUploadedFile('small.mp4', video_file.read(), "video/mp4"),
        })

        # Should redirect back to index
        self.assertRedirects(response, reverse('wagtailvideos:index'))

        # Check video exists but has no thumb or duration
        videos = Video.objects.filter(title=title)
        self.assertEqual(videos.count(), 1)
        video = videos.first()

        self.assertFalse(video.thumbnail)
        self.assertFalse(video.duration)