Пример #1
0
 def test_audiodesc_video_url_media(self):
     """Media with both Audio files and Video files attatched should be
     Video type."""
     try:
         # Create the media object
         media = self._new_publishable_media(u'description-video',
                 u'(Audio Description + Video)')
         DBSession.add(media)
         # Add an audio description
         media_file = add_new_media_file(media, None,
                 u'http://fakesite.com/fakefile.mp3')
         media_file.type = AUDIO_DESC
         media.update_status()
         # Add a video file
         media_file = add_new_media_file(media, None,
                 u'http://fakesite.com/fakefile.m4v')
         media.update_status()
         # Commit + test
         DBSession.commit()
         assert media.type == VIDEO, \
             "A Media object with a .m4v file and an Audio Description " \
             "was not labelled as a video type; it was labelled %s" % \
             (t, media.type)
     except SQLAlchemyError, e:
         DBSession.rollback()
         raise e
Пример #2
0
 def test_audiodesc_video_url_media(self):
     """Media with both Audio files and Video files attatched should be
     Video type."""
     try:
         # Create the media object
         media = self._new_publishable_media(
             u'description-video', u'(Audio Description + Video)')
         DBSession.add(media)
         # Add an audio description
         media_file = add_new_media_file(
             media, None, u'http://fakesite.com/fakefile.mp3')
         media_file.type = AUDIO_DESC
         media.update_status()
         # Add a video file
         media_file = add_new_media_file(
             media, None, u'http://fakesite.com/fakefile.m4v')
         media.update_status()
         # Commit + test
         DBSession.commit()
         assert media.type == VIDEO, \
             "A Media object with a .m4v file and an Audio Description " \
             "was not labelled as a video type; it was labelled %s" % \
             (t, media.type)
     except SQLAlchemyError, e:
         DBSession.rollback()
         raise e
Пример #3
0
    def view(self, slug, podcast_slug=None, **kwargs):
        """Display the media player, info and comments.

        :param slug: The :attr:`~mediacore.models.media.Media.slug` to lookup
        :param podcast_slug: The :attr:`~mediacore.models.podcasts.Podcast.slug`
            for podcast this media belongs to. Although not necessary for
            looking up the media, it tells us that the podcast slug was
            specified in the URL and therefore we reached this action by the
            preferred route.
        :rtype dict:
        :returns:
            media
                The :class:`~mediacore.model.media.Media` instance for display.
            related_media
                A list of :class:`~mediacore.model.media.Media` instances that
                rank as topically related to the given media item.
            comments
                A list of :class:`~mediacore.model.comments.Comment` instances
                associated with the selected media item.
            comment_form_action
                ``str`` comment form action
            comment_form_values
                ``dict`` form values
            next_episode
                The next episode in the podcast series, if this media belongs to
                a podcast, another :class:`~mediacore.model.media.Media`
                instance.

        """
        media = fetch_row(Media, slug=slug)
        request.perm.assert_permission(u'view', media.resource)

        if media.podcast_id is not None:
            # Always view podcast media from a URL that shows the context of the podcast
            if url_for() != url_for(podcast_slug=media.podcast.slug):
                redirect(podcast_slug=media.podcast.slug)

        try:
            media.increment_views()
            DBSession.commit()
        except OperationalError:
            DBSession.rollback()

        if request.settings['comments_engine'] == 'facebook':
            response.facebook = Facebook(request.settings['facebook_appid'])

        related_media = viewable_media(Media.query.related(media))[:6]
        # TODO: finish implementation of different 'likes' buttons
        #       e.g. the default one, plus a setting to use facebook.
        return dict(
            media=media,
            related_media=related_media,
            comments=media.comments.published().all(),
            comment_form_action=url_for(action='comment'),
            comment_form_values=kwargs,
        )
Пример #4
0
    def view(self, slug, podcast_slug=None, **kwargs):
        """Display the media player, info and comments.

        :param slug: The :attr:`~mediacore.models.media.Media.slug` to lookup
        :param podcast_slug: The :attr:`~mediacore.models.podcasts.Podcast.slug`
            for podcast this media belongs to. Although not necessary for
            looking up the media, it tells us that the podcast slug was
            specified in the URL and therefore we reached this action by the
            preferred route.
        :rtype dict:
        :returns:
            media
                The :class:`~mediacore.model.media.Media` instance for display.
            related_media
                A list of :class:`~mediacore.model.media.Media` instances that
                rank as topically related to the given media item.
            comments
                A list of :class:`~mediacore.model.comments.Comment` instances
                associated with the selected media item.
            comment_form_action
                ``str`` comment form action
            comment_form_values
                ``dict`` form values
            next_episode
                The next episode in the podcast series, if this media belongs to
                a podcast, another :class:`~mediacore.model.media.Media`
                instance.

        """
        media = fetch_row(Media, slug=slug)
        request.perm.assert_permission(u'view', media.resource)

        if media.podcast_id is not None:
            # Always view podcast media from a URL that shows the context of the podcast
            if url_for() != url_for(podcast_slug=media.podcast.slug):
                redirect(podcast_slug=media.podcast.slug)

        try:
            media.increment_views()
            DBSession.commit()
        except OperationalError:
            DBSession.rollback()

        if request.settings['comments_engine'] == 'facebook':
            response.facebook = Facebook(request.settings['facebook_appid'])

        related_media = viewable_media(Media.query.related(media))[:6]
        # TODO: finish implementation of different 'likes' buttons
        #       e.g. the default one, plus a setting to use facebook.
        return dict(
            media = media,
            related_media = related_media,
            comments = media.comments.published().all(),
            comment_form_action = url_for(action='comment'),
            comment_form_values = kwargs,
        )
Пример #5
0
    def test_add_file_url(self):
        slug = u'test-add-file-url'
        title = u'Test Adding File by URL on Media Edit Page.'

        try:
            media = self._new_publishable_media(slug, title)
            media.publishable = False
            media.reviewed = False
            DBSession.add(media)
            DBSession.commit()
            media_id = media.id
        except SQLAlchemyError, e:
            DBSession.rollback()
            raise e
    def test_add_file_url(self):
        slug = u'test-add-file-url'
        title = u'Test Adding File by URL on Media Edit Page.'

        try:
            media = self._new_publishable_media(slug, title)
            media.publishable = False
            media.reviewed = False
            DBSession.add(media)
            DBSession.commit()
            media_id = media.id
        except SQLAlchemyError, e:
            DBSession.rollback()
            raise e
Пример #7
0
    def _get_media(self, unique):
        """Return the media/mediafiles required for the Helpers tests"""
        try:
            media = self._new_publishable_media(u'media-selection-%s' % unique,
                    u'Media Selection Test (%s)' % unique)
            DBSession.add(media)

            media_files = {}
            for t in ['oga', 'ogv', 'm4a', 'm4v', 'flv', 'mp3', 'xml']:
                media_files[t] = add_new_media_file(media, None,
                    u'http://fakesite.com/fakefile.%s' % t)
            media_files['youtube'] = add_new_media_file(media, None,
                    u'http://www.youtube.com/watch?v=3RsbmjNLQkc')
            media.update_status()
            DBSession.commit()
        except SQLAlchemyError, e:
            DBSession.rollback()
            raise e
Пример #8
0
 def test_captioned_url_media(self):
     """Media with only subtitles attatched should be None type."""
     try:
         for t in self.caption_types:
             media = self._new_publishable_media(
                 u'caption-%s' % t, u'%s (Captioned)' % t.upper())
             DBSession.add(media)
             media_file = add_new_media_file(
                 media, None, u'http://fakesite.com/fakefile.%s' % t)
             media.update_status()
             DBSession.commit()
             assert media.type == None, \
                 "A Media object with only an .%s file associated was " \
                 "not labelled as a 'None' type; it was labelled %s" % \
                 (t, media.type)
     except SQLAlchemyError, e:
         DBSession.rollback()
         raise e
Пример #9
0
 def test_captioned_url_media(self):
     """Media with only subtitles attatched should be None type."""
     try:
         for t in self.caption_types:
             media = self._new_publishable_media(u'caption-%s' % t,
                     u'%s (Captioned)' % t.upper())
             DBSession.add(media)
             media_file = add_new_media_file(media, None,
                     u'http://fakesite.com/fakefile.%s' % t)
             media.update_status()
             DBSession.commit()
             assert media.type == None, \
                 "A Media object with only an .%s file associated was " \
                 "not labelled as a 'None' type; it was labelled %s" % \
                 (t, media.type)
     except SQLAlchemyError, e:
         DBSession.rollback()
         raise e
Пример #10
0
 def test_audio_description_url_media(self):
     """Media with only Audio Descriptions attatched should be None type."""
     try:
         for t in self.audio_types:
             media = self._new_publishable_media(u'description-%s' % t,
                     u'%s (Audio Description)' % t.upper())
             DBSession.add(media)
             media_file = add_new_media_file(media, None,
                     u'http://fakesite.com/fakefile.%s' % t)
             media_file.type = AUDIO_DESC
             media.update_status()
             DBSession.commit()
             assert media.type == None, \
                 "A Media object with only an Audio Description file " \
                 "associated was not labelled as a None type; it " \
                 "was labelled %s" % (t, media.type)
     except SQLAlchemyError, e:
         DBSession.rollback()
         raise e
Пример #11
0
    def test_edit_media(self):
        title = u'Edit Existing Media Test'
        slug = u'edit-existing-media-test' # this should be unique

        # Values that we will change during the edit process
        name = u'Frederick Awesomeson'
        email = u'*****@*****.**'
        description = u'This media item was created to test the "admin/media/edit/someID" method'
        htmlized_description = '<p>This media item was created to test the &quot;admin/media/edit/someID&quot; method</p>'
        notes = u'Some Notes!'

        try:
            media = self._new_publishable_media(slug, title)
            media.publishable = False
            media.reviewed = False
            DBSession.add(media)
            DBSession.commit()
            media_id = media.id
        except SQLAlchemyError, e:
            DBSession.rollback()
            raise e
    def test_edit_media(self):
        title = u'Edit Existing Media Test'
        slug = u'edit-existing-media-test'  # this should be unique

        # Values that we will change during the edit process
        name = u'Frederick Awesomeson'
        email = u'*****@*****.**'
        description = u'This media item was created to test the "admin/media/edit/someID" method'
        htmlized_description = '<p>This media item was created to test the &quot;admin/media/edit/someID&quot; method</p>'
        notes = u'Some Notes!'

        try:
            media = self._new_publishable_media(slug, title)
            media.publishable = False
            media.reviewed = False
            DBSession.add(media)
            DBSession.commit()
            media_id = media.id
        except SQLAlchemyError, e:
            DBSession.rollback()
            raise e