Esempio n. 1
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')))
Esempio n. 2
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())
Esempio n. 3
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)
Esempio n. 4
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())
Esempio n. 5
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())
Esempio n. 6
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())
Esempio n. 7
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')
Esempio n. 8
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')
Esempio n. 9
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'))

        # This test and the code it tests hasn't changed in
        # months. However, this test started failing for Mike and I
        # early July 2013. We think we picked up libxml2 2.9.1 and
        # that causes the output to be different.  I contend that the
        # output and expected output are both "wrong" in that they're
        # invalid html5 and the output I'm getting isn't really any
        # worse. Ergo, I have changed the test to accept either output
        # because I got stuff to do. Having said that, this is kind of
        # ridiculous and should be fixed. See bug #892610.
        assert doc('video').html() in [
            # This was the original expected test output.
            (u'<source src="{0}" '
             u'type="video/webm"><source src="{1}" type="video/ogg"/>'
             u'</source>'.format(v.webm.url, v.ogv.url)),

            # This is the version that Mike and I get.
            (u'\n          <source src="{0}" type="video/webm">'
             u'\n          <source src="{1}" type="video/ogg">'
             u'\n      </source></source>'.format(v.webm.url, v.ogv.url))]

        eq_(1, len(doc('video')))
        eq_(2, len(doc('source')))
        data_fallback = doc('video').attr('data-fallback')
        eq_(v.flv.url, data_fallback)
Esempio n. 10
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')
Esempio n. 11
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'))

        # This test and the code it tests hasn't changed in
        # months. However, this test started failing for Mike and I
        # early July 2013. We think we picked up libxml2 2.9.1 and
        # that causes the output to be different.  I contend that the
        # output and expected output are both "wrong" in that they're
        # invalid html5 and the output I'm getting isn't really any
        # worse. Ergo, I have changed the test to accept either output
        # because I got stuff to do. Having said that, this is kind of
        # ridiculous and should be fixed. See bug #892610.
        assert doc('video').html() in [
            # This was the original expected test output.
            (u'<source src="{0}" '
             u'type="video/webm"><source src="{1}" type="video/ogg"/>'
             u'</source>'.format(v.webm.url, v.ogv.url)),

            # This is the version that Mike and I get.
            (u'\n          <source src="{0}" type="video/webm">'
             u'\n          <source src="{1}" type="video/ogg">'
             u'\n      </source></source>'.format(v.webm.url, v.ogv.url))
        ]

        eq_(1, len(doc('video')))
        eq_(2, len(doc('source')))
        data_fallback = doc('video').attr('data-fallback')
        eq_(v.flv.url, data_fallback)
Esempio n. 12
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'))
Esempio n. 13
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'))
Esempio n. 14
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)
Esempio n. 15
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)
Esempio n. 16
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')
Esempio n. 17
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')
Esempio n. 18
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')
Esempio n. 19
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')