Exemplo n.º 1
0
 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())
Exemplo n.º 2
0
 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')))
Exemplo n.º 3
0
 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())
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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())
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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())
Exemplo n.º 10
0
 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())
Exemplo n.º 11
0
    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")
Exemplo n.º 12
0
    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')
Exemplo n.º 13
0
    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')
Exemplo n.º 14
0
 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')
Exemplo n.º 15
0
 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')
Exemplo n.º 16
0
 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"))
Exemplo n.º 17
0
 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'))
Exemplo n.º 18
0
 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'))
Exemplo n.º 19
0
 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)
Exemplo n.º 20
0
 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)
Exemplo n.º 21
0
 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)
Exemplo n.º 22
0
 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')
Exemplo n.º 23
0
 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')
Exemplo n.º 24
0
 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)
Exemplo n.º 25
0
 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')
Exemplo n.º 26
0
 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')
Exemplo n.º 27
0
 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')