Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video_saved signal noop when raw #35

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import unicode_literals

from unittest.mock import Mock

from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase, override_settings
from wagtail.tests.utils import WagtailTestUtils

from tests.utils import create_test_video_file
from wagtailvideos.models import Video, video_saved

class TestVideoModel(WagtailTestUtils, TestCase):

def test_post_save_signal_raw(self):
'''
When called with the 'raw' kwarg, the post_save signal handler should
do nothing. We will test this by asserting that it never calls save
on the instance.
'''
mocked_instance = Mock()
del mocked_instance._from_signal
video_saved(Video, mocked_instance, raw=True)
assert not mocked_instance.save.called
3 changes: 3 additions & 0 deletions wagtailvideos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ def video_saved(sender, instance, **kwargs):
if not ffmpeg.installed():
return

if 'raw' in kwargs and kwargs['raw']:
return

if hasattr(instance, '_from_signal'):
return

Expand Down