Exemplo n.º 1
0
 def setUp(self):
     self.dv_from_key_patcher = (mock.patch(
         'mediaplatform_jwp.api.delivery.DeliveryVideo.from_key'))
     self.dv_from_key = self.dv_from_key_patcher.start()
     self.dv_from_key.return_value = jwplatform.DeliveryVideo(
         DELIVERY_VIDEO_FIXTURE)
     self.addCleanup(self.dv_from_key_patcher.stop)
Exemplo n.º 2
0
 def test_no_args(self):
     """Passing no arguments returns the "best" source."""
     sources = [
         {
             'type': 'video/mp4',
             'width': 720,
             'height': 406,
             'file': 'http://cdn.invalid/vid2.mp4',
         },
         {
             'type': 'video/mp4',
             'width': 1920,
             'height': 1080,
             'file': 'http://cdn.invalid/vid1.mp4',
         },
         {
             'type': 'audio/mp4',
             'file': 'http://cdn.invalid/vid_audio.mp4',
         },
     ]
     self.dv_from_key.return_value = api.DeliveryVideo({
         **DELIVERY_VIDEO_FIXTURE, 'sources':
         sources
     })
     source = sources[1]
     response = self.get()
     self.assertRedirects(response,
                          source['file'],
                          fetch_redirect_response=False)
Exemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.view = views.MediaItemView().as_view()
     self.dv_from_key_patcher = (mock.patch(
         'mediaplatform_jwp.api.delivery.DeliveryVideo.from_key'))
     self.dv_from_key = self.dv_from_key_patcher.start()
     self.dv_from_key.return_value = api.DeliveryVideo(
         DELIVERY_VIDEO_FIXTURE)
     self.addCleanup(self.dv_from_key_patcher.stop)
Exemplo n.º 4
0
    def setUp(self):
        super().setUp()
        dv_patch = mock.patch(
            'mediaplatform_jwp.api.delivery.DeliveryVideo.from_key')
        self.mock_from_id = dv_patch.start()
        self.mock_from_id.return_value = api.DeliveryVideo(
            DELIVERY_VIDEO_FIXTURE)
        self.addCleanup(dv_patch.stop)

        get_profile_patch = mock.patch('api.views.get_profile')
        self.get_profile = get_profile_patch.start()
        self.get_profile.return_value = {'user': AnonymousUser()}
        self.addCleanup(get_profile_patch.stop)
Exemplo n.º 5
0
    def setUp(self):
        super().setUp()
        dv_patch = mock.patch(
            'mediaplatform_jwp.api.delivery.DeliveryVideo.from_key')
        self.mock_from_id = dv_patch.start()
        self.mock_from_id.return_value = api.DeliveryVideo(
            DELIVERY_VIDEO_FIXTURE)
        self.addCleanup(dv_patch.stop)

        get_person_patch = mock.patch('automationlookup.get_person')
        self.get_person = get_person_patch.start()
        self.get_person.return_value = {}
        self.addCleanup(get_person_patch.stop)
Exemplo n.º 6
0
    def setUp(self):
        super().setUp()
        self.view = views.MediaItemSourceView().as_view()
        self.item = self.non_deleted_media.get(id='populated')
        self.dv_from_key_patcher = (mock.patch(
            'mediaplatform_jwp.api.delivery.DeliveryVideo.from_key'))
        self.dv_from_key = self.dv_from_key_patcher.start()
        self.dv_from_key.return_value = api.DeliveryVideo(
            DELIVERY_VIDEO_FIXTURE)
        self.addCleanup(self.dv_from_key_patcher.stop)

        # Make sure item is downloadable
        self.item.downloadable = True
        self.item.save()
Exemplo n.º 7
0
    def test_no_html_in_page(self):
        """checks that HTML in descriptions, etc is escaped."""
        self.mock_from_id.return_value = api.DeliveryVideo(
            DELIVERY_VIDEO_FIXTURE)
        item = self.non_deleted_media.get(id='populated')

        item.title = '<some-tag>'
        item.save()

        r = self.client.get(reverse('ui:media_item', kwargs={'pk': item.pk}))

        self.assertEqual(r.status_code, 200)
        self.assertTemplateUsed(r, 'ui/media.html')
        content = r.content.decode('utf8')
        self.assertNotIn('<some-tag>', content)
Exemplo n.º 8
0
 def test_audio_best_source(self):
     """Best source will include audio if that is all there is."""
     sources = [
         {
             'type': 'something/else',
             'file': 'http://cdn.invalid/vid_odd.mp4',
         },
         {
             'type': 'audio/mp4',
             'file': 'http://cdn.invalid/vid_audio.mp4',
         },
     ]
     self.dv_from_key.return_value = api.DeliveryVideo({
         **DELIVERY_VIDEO_FIXTURE, 'sources':
         sources
     })
     source = sources[1]
     response = self.get()
     self.assertRedirects(response,
                          source['file'],
                          fetch_redirect_response=False)