def test_unicode_name(self):
     name = u'\u1015\u103c\u1031\u102c\u1004\u103a\u1038\u200b\u1016\u1030\u1038\u200b\u1000\u103c\u1031\u102c\u103a\u200b\u101b\u200b\u1021\u1031\u102c\u1004\u103a\u200b'
     slug = u'\u1015\u1004\u1016\u1000\u101b\u1021\u1004'
     video = self.create_video(name)
     view = VideoView()
     view.request = self.factory.get(video.get_absolute_url())
     view.kwargs = {'slug': slug, 'video_id': video.pk}
     response = view.get(view.request)
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 2
0
 def test_unicode_name(self):
     name = u'\u1015\u103c\u1031\u102c\u1004\u103a\u1038\u200b\u1016\u1030\u1038\u200b\u1000\u103c\u1031\u102c\u103a\u200b\u101b\u200b\u1021\u1031\u102c\u1004\u103a\u200b'
     slug = u'\u1015\u1004\u1016\u1000\u101b\u1021\u1004'
     video = self.create_video(name)
     view = VideoView()
     view.request = self.factory.get(video.get_absolute_url())
     view.kwargs = {'slug': slug, 'video_id': video.pk}
     response = view.get(view.request)
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 3
0
    def test_get_queryset(self):
        """The queryset should be this site's active videos."""
        video1 = self.create_video(site_id=settings.SITE_ID)
        video2 = self.create_video(site_id=settings.SITE_ID)
        self.create_video(status=Video.UNAPPROVED)
        self.create_video(site_id=settings.SITE_ID + 1)

        view = VideoView()
        view.request = self.factory.get('/')
        results = set(view.get_queryset())
        self.assertEqual(results, set((video1, video2)))
Ejemplo n.º 4
0
    def test_get_queryset(self):
        """The queryset should be this site's active videos."""
        video1 = self.create_video(site_id=settings.SITE_ID)
        video2 = self.create_video(site_id=settings.SITE_ID)
        self.create_video(status=Video.UNAPPROVED)
        self.create_video(site_id=settings.SITE_ID + 1)

        view = VideoView()
        view.request = self.factory.get("/")
        results = set(view.get_queryset())
        self.assertEqual(results, set((video1, video2)))
Ejemplo n.º 5
0
    def test_get_queryset(self):
        """The queryset should be this site's active videos."""
        site1 = Site.objects.get_current()
        site2 = Site.objects.create(name='test', domain='test.com')
        video1 = self.create_video(site_id=site1.pk)
        video2 = self.create_video(site_id=site1.pk)
        self.create_video(status=Video.UNAPPROVED)
        self.create_video(site_id=site2.pk)

        view = VideoView()
        view.request = self.factory.get('/')
        results = set(view.get_queryset())
        self.assertEqual(results, set((video1, video2)))
    def test_get_queryset(self):
        """The queryset should be this site's active videos."""
        site1 = Site.objects.get_current()
        site2 = Site.objects.create(name='test', domain='test.com')
        video1 = self.create_video(site_id=site1.pk)
        video2 = self.create_video(site_id=site1.pk)
        self.create_video(status=Video.UNAPPROVED)
        self.create_video(site_id=site2.pk)

        view = VideoView()
        view.request = self.factory.get('/')
        results = set(view.get_queryset())
        self.assertEqual(results, set((video1, video2)))
Ejemplo n.º 7
0
    def test_context__category(self):
        """
        If the video has categories, the VideoView should include a category
        in its context_data and limit the provided popular videos to that
        category.

        """
        category = self.create_category(name="Category")
        video1 = self.create_video("test1", watches=5, categories=[category])
        video2 = self.create_video("test2", watches=4, categories=[category])
        video3 = self.create_video("test3", watches=3, categories=[category])
        video4 = self.create_video("test4", watches=20)
        video5 = self.create_video("test5", watches=0, categories=[category])

        view = VideoView()
        view.request = self.factory.get("/")
        view.object = video1
        context = view.get_context_data(object=video1)
        self.assertEqual(context["category"].pk, category.pk)
        self.assertEqual(list(context["popular_videos"]), [video1, video2, video3, video5])
Ejemplo n.º 8
0
    def test_context__category(self):
        """
        If the video has categories, the VideoView should include a category
        in its context_data and limit the provided popular videos to that
        category.

        """
        category = self.create_category(name='Category')
        video1 = self.create_video('test1', watches=5, categories=[category])
        video2 = self.create_video('test2', watches=4, categories=[category])
        video3 = self.create_video('test3', watches=3, categories=[category])
        video4 = self.create_video('test4', watches=20)
        video5 = self.create_video('test5', watches=0, categories=[category])

        view = VideoView()
        view.request = self.factory.get('/')
        view.object = video1
        context = view.get_context_data(object=video1)
        self.assertEqual(context['category'].pk, category.pk)
        self.assertEqual(list(context['popular_videos']),
                         [video1, video2, video3, video5])
from django.views.generic import ListView

from localtv.api.v1 import api as api_v1
from localtv.listing.views import CompatibleListingView, SiteListView
from localtv.models import Category
from localtv.views import IndexView, VideoView


# "Base" patterns
urlpatterns = patterns(
    'localtv.views',
    url(r'^$', IndexView.as_view(), name='localtv_index'),
    url(r'^about/$', 'about', name='localtv_about'),
    url(r'^share/(\d+)/(\d+)', 'share_email', name='email-share'),
    url(r'^video/(?P<video_id>[0-9]+)(?:/(?P<slug>[\w~-]+))?/?$',
        VideoView.as_view(),
        name='localtv_view_video'),
    url(r'^api/', include(api_v1.urls)))

# Listing patterns
# This has to be importable for now because of a hack in the view_video view
# which imports this view to check whether the referer was a category page.
category_videos = CompatibleListingView.as_view(
    template_name='localtv/category.html',
    filter_name='category',
    filter_kwarg='slug'
)
urlpatterns += patterns(
    'localtv.listing.views',
    url(r'^search/$', CompatibleListingView.as_view(
                        template_name='localtv/video_listing_search.html',
Ejemplo n.º 10
0
from django.views.generic import ListView

from localtv.api.v1 import api as api_v1
from localtv.listing.views import CompatibleListingView, SiteListView
from localtv.models import Category
from localtv.views import IndexView, VideoView


# "Base" patterns
urlpatterns = patterns(
    'localtv.views',
    url(r'^$', IndexView.as_view(), name='localtv_index'),
    url(r'^about/$', 'about', name='localtv_about'),
    url(r'^share/(\d+)/(\d+)', 'share_email', name='email-share'),
    url(r'^video/(?P<video_id>[0-9]+)(?:/(?P<slug>[\w-]+))?/?$',
        VideoView.as_view(),
        name='localtv_view_video'),
    url(r'^newsletter/$', 'newsletter', name='localtv_newsletter'),
    url(r'^api/', include(api_v1.urls)))

# Listing patterns
# This has to be importable for now because of a hack in the view_video view
# which imports this view to check whether the referer was a category page.
category_videos = CompatibleListingView.as_view(
    template_name='localtv/category.html',
    filter_name='category',
    filter_kwarg='slug'
)
urlpatterns += patterns(
    'localtv.listing.views',
    url(r'^search/$', CompatibleListingView.as_view(