Example #1
0
    def test_category_feed(self):
        """Tests for Category rss feed"""

        # Test that only categories with live videos are included.
        feed = CategoryFeed()

        cat = category(save=True)
        video(category=cat, save=True)
        v2 = video(category=cat, save=True)

        # No live videos, no category in feed
        eq_(len(feed.items()), 0)

        # At least one video is live, category is included
        v2.state = Video.STATE_LIVE
        v2.save()
        eq_([x.pk for x in feed.items()], [cat.pk])

        # Category feed description_template exists.
        found_tpl = True
        try:
            get_template(feed.description_template)
        except TemplateDoesNotExist:
            found_tpl = False
        eq_(found_tpl, True)

        # Category list feeds is accessible.
        resp = self.client.get(reverse('videos-category-feed'))
        eq_(resp.status_code, 200)

        # Category videos feed is accessible.
        resp = self.client.get(
            reverse('videos-category-videos-feed',
                    kwargs={
                        'category_id': cat.id,
                        'slug': cat.slug
                    }))
        eq_(resp.status_code, 200)

        # Category videos feed returns 404, invalid category_id.
        resp = self.client.get(
            reverse('videos-category-videos-feed',
                    kwargs={
                        'category_id': 50,
                        'slug': 'fake-slug'
                    }))
        eq_(resp.status_code, 404)
Example #2
0
    def test_category_feed(self):
        """Tests for Category rss feed"""

        # Test that only categories with live videos are included.
        feed = CategoryFeed()

        cat = factories.CategoryFactory()
        factories.VideoFactory(category=cat)
        v2 = factories.VideoFactory(category=cat)

        # No live videos, no category in feed
        assert len(feed.items()) == 0

        # At least one video is live, category is included
        v2.state = Video.STATE_LIVE
        v2.save()
        assert [x.pk for x in feed.items()] == [cat.pk]

        # Category feed description_template exists.
        found_tpl = True
        try:
            get_template(feed.description_template)
        except TemplateDoesNotExist:
            found_tpl = False
        assert found_tpl == True

        # Category list feeds is accessible.
        resp = self.client.get(reverse('videos-category-feed'))
        assert resp.status_code == 200

        # Category videos feed is accessible.
        resp = self.client.get(
            reverse('videos-category-videos-feed',
                    kwargs={
                        'category_id': cat.id,
                        'slug': cat.slug
                    }))
        assert resp.status_code == 200

        # Category videos feed returns 404, invalid category_id.
        resp = self.client.get(
            reverse('videos-category-videos-feed',
                    kwargs={
                        'category_id': 50,
                        'slug': 'fake-slug'
                    }))
        assert resp.status_code == 404
Example #3
0
    def test_category_feed(self):
        """Tests for Category rss feed"""

        # Test that only categories with live videos are included.
        feed = CategoryFeed()

        cat = category(save=True)
        video(category=cat, save=True)
        v2 = video(category=cat, save=True)

        # No live videos, no category in feed
        eq_(len(feed.items()), 0)

        # At least one video is live, category is included
        v2.state = Video.STATE_LIVE
        v2.save()
        eq_([x.pk for x in feed.items()], [cat.pk])

        # Category feed description_template exists.
        found_tpl = True
        try:
            get_template(feed.description_template)
        except TemplateDoesNotExist:
            found_tpl = False
        eq_(found_tpl, True)

        # Category list feeds is accessible.
        resp = self.client.get(reverse('videos-category-feed'))
        eq_(resp.status_code, 200)

        # Category videos feed is accessible.
        resp = self.client.get(
            reverse(
                'videos-category-videos-feed',
                kwargs={'category_id': cat.id, 'slug': cat.slug}))
        eq_(resp.status_code, 200)

        # Category videos feed returns 404, invalid category_id.
        resp = self.client.get(
            reverse(
                'videos-category-videos-feed',
                kwargs={'category_id': 50, 'slug': 'fake-slug'}))
        eq_(resp.status_code, 404)
Example #4
0
    def test_category_feed(self):
        """Tests for Category rss feed"""

        # Test that only categories with live videos are included.
        feed = CategoryFeed()

        cat = factories.CategoryFactory()
        factories.VideoFactory(category=cat)
        v2 = factories.VideoFactory(category=cat)

        # No live videos, no category in feed
        assert len(feed.items()) == 0

        # At least one video is live, category is included
        v2.state = Video.STATE_LIVE
        v2.save()
        assert [x.pk for x in feed.items()] == [cat.pk]

        # Category feed description_template exists.
        found_tpl = True
        try:
            get_template(feed.description_template)
        except TemplateDoesNotExist:
            found_tpl = False
        assert found_tpl == True

        # Category list feeds is accessible.
        resp = self.client.get(reverse('videos-category-feed'))
        assert resp.status_code == 200

        # Category videos feed is accessible.
        resp = self.client.get(
            reverse(
                'videos-category-videos-feed',
                kwargs={'category_id': cat.id, 'slug': cat.slug}))
        assert resp.status_code == 200

        # Category videos feed returns 404, invalid category_id.
        resp = self.client.get(
            reverse(
                'videos-category-videos-feed',
                kwargs={'category_id': 50, 'slug': 'fake-slug'}))
        assert resp.status_code == 404
Example #5
0
from richard.videos.feeds import (CategoryFeed, CategoryVideosFeed,
                                  SpeakerVideosFeed, NewPostedVideoFeed)
from richard.videos.views import (CategoryListAPI, CategoryRetrieveAPI,
                                  VideoListCreateAPI, VideoRetrieveUpdateAPI,
                                  SpeakerListAPI)

urlpatterns = patterns(
    'richard.videos.views',

    # categories
    url(r'^category/?$', 'category_list', name='videos-category-list'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/?$',
        'category',
        name='videos-category'),
    url(r'^category/rss/?$', CategoryFeed(), name='videos-category-feed'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/rss/?$',
        CategoryVideosFeed(),
        name='videos-category-videos-feed'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/files/?$',
        'category_files',
        name='videos-category-files'),

    # speakers
    url(r'^speaker/$', 'speaker_list', name='videos-speaker-list'),
    url(r'^speaker/(?P<speaker_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/?$',
        'speaker',
        name='videos-speaker'),
    url(r'^speaker/(?P<speaker_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/rss/?$',
        SpeakerVideosFeed(),
        name='videos-speaker-feed'),
Example #6
0
from richard.videos.api import VideoResource, CategoryResource
from richard.videos.feeds import (
    CategoryFeed, CategoryVideosFeed, SpeakerVideosFeed,
    NewPostedVideoFeed)


urlpatterns = patterns(
    'richard.videos.views',

    # categories
    url(r'^category/?$',
        'category_list', name='videos-category-list'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/?$',
        'category', name='videos-category'),
    url(r'^category/rss/?$',
        CategoryFeed(), name='videos-category-feed'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/rss/?$',
        CategoryVideosFeed(), name='videos-category-videos-feed'),
    url(r'^category/(?P<category_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/files/?$',
        'category_files', name='videos-category-files'),

    # speakers
    url(r'^speaker/$',
        'speaker_list', name='videos-speaker-list'),
    url(r'^speaker/(?P<speaker_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/?$',
        'speaker', name='videos-speaker'),
    url(r'^speaker/(?P<speaker_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/rss/?$',
        SpeakerVideosFeed(), name='videos-speaker-feed'),

    # videos
    url(r'^video/(?P<video_id>[0-9]+)(?:/(?P<slug>[\w-]*))?/?$',