Exemplo n.º 1
0
 def test_video_search(self):
     VideoFactory(title="0a85171f1802a3b0d9f46ffb997ddc02-1251659983-259-2.mp4")
     VideoFactory(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.º 2
0
 def test_video_search(self):
     VideoFactory(
         title='0a85171f1802a3b0d9f46ffb997ddc02-1251659983-259-2.mp4')
     VideoFactory(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_modal(self):
     """Video modal defaults for plcaeholder and text."""
     v = VideoFactory()
     replacement = '<img class="video-thumbnail" src="%s"/>' % v.thumbnail_url_if_set()
     d = ApprovedRevisionFactory(content="[[V:%s|modal]]" % v.title).document
     doc = pq(d.html)
     eq_(v.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.º 4
0
 def test_video_modal(self):
     """Video modal defaults for plcaeholder and text."""
     v = VideoFactory()
     replacement = ('<img class="video-thumbnail" src="%s"/>' % v.thumbnail_url_if_set())
     d = ApprovedRevisionFactory(content='[[V:%s|modal]]' % v.title).document
     doc = pq(d.html)
     eq_(v.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.º 5
0
 def test_video_modal(self):
     """Video modal defaults for plcaeholder and text."""
     v = VideoFactory()
     replacement = ('<img class="video-thumbnail" src="%s"/>' %
                    v.thumbnail_url_if_set())
     d = ApprovedRevisionFactory(content='[[V:%s|modal]]' %
                                 v.title).document
     doc = pq(d.html)
     eq_(v.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.º 6
0
    def test_video_english(self):
        """Video is created and found in English."""
        v = VideoFactory()
        d = ApprovedRevisionFactory(content="[[V:%s]]" % v.title).document
        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.
            (
                '<source src="{0}" '
                'type="video/webm"><source src="{1}" type="video/ogg"/>'
                "</source>".format(v.webm.url, v.ogv.url)
            ),
            # This is the version that Mike and I get.
            (
                '\n          <source src="{0}" type="video/webm">'
                '\n          <source src="{1}" type="video/ogg">'
                "\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)
Exemplo n.º 7
0
 def test_video_cdn(self):
     """Video URLs can link to the CDN if a CDN setting is set."""
     v = VideoFactory()
     d = ApprovedRevisionFactory(content="[[V:%s]]" % v.title).document
     doc = pq(d.html)
     assert settings.GALLERY_VIDEO_URL in doc("source").eq(1).attr("src")
     assert settings.GALLERY_VIDEO_URL in doc("video").attr("data-fallback")
     assert settings.GALLERY_VIDEO_URL in doc("source").eq(0).attr("src")
Exemplo n.º 8
0
 def test_video_draft_post(self):
     """Posting to the page saves the field values for the video draft."""
     VideoFactory(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.º 9
0
 def test_video_modal_caption_text(self):
     """Video modal can change title and placeholder text."""
     v = VideoFactory()
     r = ApprovedRevisionFactory(
         content="[[V:%s|modal|placeholder=Place<b>holder</b>|title=WOOT]]" % v.title
     )
     d = r.document
     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_fallback_french(self):
     """English video is found in French."""
     p = WikiParser()
     v = VideoFactory()
     doc = pq(p.parse("[[V:%s]]" % v.title, locale="fr"))
     eq_("video", doc("div.video").attr("class"))
     eq_(1, len(doc("video")))
     eq_(2, len(doc("source")))
     data_fallback = doc("video").attr("data-fallback")
     eq_(Video.objects.all()[0].flv.url, data_fallback)
Exemplo n.º 11
0
 def test_video_modal_caption_text(self):
     """Video modal can change title and placeholder text."""
     v = VideoFactory()
     r = ApprovedRevisionFactory(
         content='[[V:%s|modal|placeholder=Place<b>holder</b>|title=WOOT]]'
         % v.title)
     d = r.document
     doc = pq(d.html)
     eq_('WOOT', doc('.video-modal')[0].attrib['title'])
     eq_('Place<b>holder</b>', doc('.video-placeholder').html().strip())
Exemplo n.º 12
0
 def test_video_fallback_french(self):
     """English video is found in French."""
     p = WikiParser()
     v = VideoFactory()
     doc = pq(p.parse('[[V:%s]]' % v.title, locale='fr'))
     eq_('video', doc('div.video').attr('class'))
     eq_(1, len(doc('video')))
     eq_(2, len(doc('source')))
     data_fallback = doc('video').attr('data-fallback')
     eq_(Video.objects.all()[0].flv.url, data_fallback)
Exemplo n.º 13
0
 def test_check_has_perm(self):
     """User with django permission has perm to change video."""
     vid = VideoFactory(creator=self.user)
     u = UserFactory()
     add_permission(u, Video, "change_video")
     check_media_permissions(vid, u, "change")
Exemplo n.º 14
0
 def test_check_own_object(self):
     """tagger can edit a video s/he doesn't own."""
     vid = VideoFactory(creator=self.user)
     check_media_permissions(vid, self.user, "change")
Exemplo n.º 15
0
 def test_get_media_info_video(self):
     """Gets video and format info."""
     vid = VideoFactory()
     info_vid, info_format = _get_media_info(vid.pk, 'video')
     eq_(vid.pk, info_vid.pk)
     eq_(None, info_format)