def test_video_modal_caption_text(self): """Video modal can change title and placeholder text.""" video() d, _, p = doc_rev_parser("[[V:Some title|modal|placeholder=Place<b>holder</b>|title=WOOT]]") doc = pq(d.html) eq_("WOOT", doc(".video-modal")[0].attrib["title"]) eq_("Place<b>holder</b>", doc(".video-placeholder").html().strip())
def test_video_search(self): video(title='0a85171f1802a3b0d9f46ffb997ddc02-1251659983-259-2.mp4') video(title='another-video.mp4') url = reverse('gallery.search', args=['video']) response = self.client.get(url, {'q': '1802'}, follow=True) doc = pq(response.content) eq_(1, len(doc('#media-list li')))
def test_video_draft_post(self): """Posting to the page saves the field values for the video draft.""" video(is_draft=True, creator=self.u) response = post(self.client, "gallery.gallery", {"title": "zTestz"}, args=["image"]) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_("zTestz", doc('#gallery-upload-modal input[name="title"]').val())
def test_video_draft_shows(self): """The video draft is loaded for this user.""" video(title=get_draft_title(self.u), creator=self.u) response = get(self.client, 'gallery.gallery', args=['image']) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_(3, doc('ul li.video-preview').length)
def test_video_draft_shows(self): """The video draft is loaded for this user.""" video(title=get_draft_title(self.u), creator=self.u) response = get(self.client, "gallery.gallery", args=["image"]) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_(3, doc("ul li.video-preview").length)
def test_video_draft_shows(self): """The video draft is loaded for this user.""" video(is_draft=True, creator=self.u) response = get(self.client, 'gallery.gallery', args=['image']) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_(3, doc('#gallery-upload-video .preview input').length)
def test_video_modal_caption_text(self): """Video modal can change title and placeholder text.""" video() d, _, p = doc_rev_parser( '[[V:Some title|modal|placeholder=Place<b>holder</b>|title=WOOT]]') doc = pq(d.html) eq_('WOOT', doc('.video-modal')[0].attrib['title']) eq_('Place<b>holder</b>', doc('.video-placeholder').html().strip())
def test_video_draft_shows(self): """The video draft is loaded for this user.""" video(is_draft=True, creator=self.u) response = get(self.client, "gallery.gallery", args=["image"]) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_(3, doc("#gallery-upload-video .preview input").length)
def test_video_draft_post(self): """Posting to the page saves the field values for the video draft.""" video(title=get_draft_title(self.u), creator=self.u) response = post(self.client, 'gallery.gallery', {'title': 'zTestz'}, args=['image']) eq_(200, response.status_code) doc = pq(response.content) # Preview for all 3 video formats: flv, ogv, webm eq_('zTestz', doc('#gallery-upload-modal input[name="title"]').val())
def test_video_cdn(self): """Video URLs can link to the CDN if a CDN setting is set.""" video() cdn_url = "http://videos.mozilla.org/serv/sumo/" self.old_settings = settings.GALLERY_VIDEO_URL settings.GALLERY_VIDEO_URL = cdn_url d, _, p = doc_rev_parser("[[V:Some title]]") settings.GALLERY_VIDEO_URL = self.old_settings doc = pq(d.html) assert cdn_url in doc("video").attr("data-fallback") assert cdn_url in doc("source").eq(0).attr("src") assert cdn_url in doc("source").eq(1).attr("src")
def test_video_cdn(self): """Video URLs can link to the CDN if a CDN setting is set.""" video() cdn_url = 'http://videos.mozilla.org/serv/sumo/' self.old_settings = deepcopy(settings._wrapped.__dict__) settings.GALLERY_VIDEO_URL = cdn_url d, _, p = doc_rev_parser('[[V:Some title]]') settings._wrapped.__dict__ = self.old_settings doc = pq(d.html) assert cdn_url in doc('video').attr('data-fallback') assert cdn_url in doc('source').eq(0).attr('src') assert cdn_url in doc('source').eq(1).attr('src')
def test_video_cdn(self): """Video URLs can link to the CDN if a CDN setting is set.""" video() cdn_url = 'http://videos.mozilla.org/serv/sumo/' self.old_settings = settings.GALLERY_VIDEO_URL settings.GALLERY_VIDEO_URL = cdn_url d, _, p = doc_rev_parser('[[V:Some title]]') settings.GALLERY_VIDEO_URL = self.old_settings doc = pq(d.html) assert cdn_url in doc('video').attr('data-fallback') assert cdn_url in doc('source').eq(0).attr('src') assert cdn_url in doc('source').eq(1).attr('src')
def test_new_video(self): """New Video is created and saved""" vid = video() eq_('Some title', vid.title) assert vid.webm.name.endswith('098f6b.webm') assert vid.ogv.name.endswith('098f6b.ogv') assert vid.flv.name.endswith('098f6b.flv')
def test_video_modal(self): """Video modal defaults for plcaeholder and text.""" v = video() replacement = '<img class="video-thumbnail" src="%s"/>' % v.thumbnail_url_if_set() d, _, p = doc_rev_parser("[[V:Some title|modal]]") doc = pq(d.html) eq_("Some title", doc(".video-modal")[0].attrib["title"]) eq_(1, doc(".video video").length) eq_(replacement, doc(".video-placeholder").html().strip()) eq_("video modal-trigger", doc("div.video").attr("class"))
def test_video_modal(self): """Video modal defaults for plcaeholder and text.""" v = video() replacement = ('<img class="video-thumbnail" src="%s"/>' % v.thumbnail_url_if_set()) d, _, p = doc_rev_parser('[[V:Some title|modal]]') doc = pq(d.html) eq_('Some title', doc('.video-modal')[0].attrib['title']) eq_(1, doc('.video video').length) eq_(replacement, doc('.video-placeholder').html().strip()) eq_('video modal-trigger', doc('div.video').attr('class'))
def test_video_modal(self): """Video modal defaults for plcaeholder and text.""" v = video() replacement = ('<img class="video-thumbnail" src="%s"/>' % v.thumbnail_url_if_set()) d, _, p = doc_rev_parser( '[[V:Some title|modal]]') doc = pq(d.html) eq_('Some title', doc('.video-modal')[0].attrib['title']) eq_(1, doc('.video video').length) eq_(replacement, doc('.video-placeholder').html().strip()) eq_('video modal-trigger', doc('div.video').attr('class'))
def test_video_english(self): """Video is created and found in English.""" v = video() d, _, p = doc_rev_parser('[[V:Some title]]') doc = pq(d.html) eq_('video', doc('div.video').attr('class')) eq_(u'<source src="{0}" ' u'type="video/webm"><source src="{1}" type="video/ogg"/>' u'</source>'.format(v.webm.url, v.ogv.url), doc('video').html()) eq_(1, len(doc('video'))) eq_(2, len(doc('source'))) data_fallback = doc('video').attr('data-fallback') eq_(v.flv.url, data_fallback)
def test_video_english(self): """Video is created and found in English.""" v = video() d, _, p = doc_rev_parser("[[V:Some title]]") doc = pq(d.html) eq_("video", doc("div.video").attr("class")) eq_( u'<source src="{0}" ' u'type="video/webm"><source src="{1}" type="video/ogg"/>' u"</source>".format(v.webm.url, v.ogv.url), doc("video").html(), ) eq_(1, len(doc("video"))) eq_(2, len(doc("source"))) data_fallback = doc("video").attr("data-fallback") eq_(v.flv.url, data_fallback)
def test_check_has_perm(self): """Admin has perm to change video.""" u = User.objects.get(username='******') vid = video(creator=u) check_media_permissions(vid, u, 'change')
def test_check_own_object(self): """tagger can edit a video s/he doesn't own.""" vid = video(creator=self.user) check_media_permissions(vid, self.user, 'change')
def test_get_media_info_video(self): """Gets video and format info.""" vid = video() info_vid, info_format = _get_media_info(vid.pk, 'video') eq_(vid.pk, info_vid.pk) eq_(None, info_format)
def test_check_has_perm(self): """User with django permission has perm to change video.""" vid = video(creator=self.user) u = user(save=True) add_permission(u, Video, 'change_video') check_media_permissions(vid, u, 'change')