示例#1
0
    def setUp(self):
        super(GalleryTests, self).setUp()
        self.us_user = UserProfileFactory.create(country='us').user
        self.fr_user = UserProfileFactory.create(country='fr').user

        self.v1 = VideoFactory.create(user=self.us_user, approved=True)
        self.v2 = VideoFactory.create(user=self.fr_user, approved=True)
示例#2
0
    def test_title_sort(self):
        """By default, sort videos alphabetically by their title."""
        video_1 = VideoFactory.create(title="A", approved=True)
        video_2 = VideoFactory.create(title="C", approved=True)
        video_3 = VideoFactory.create(title="B", approved=True)

        eq_(list(search_videos()), [video_1, video_3, video_2])
示例#3
0
    def test_valid_page(self):
        # Create more videos to get past 12
        for _ in range(14):
            VideoFactory.create(approved=True)

        ctx = self._video_list_ctx(page=2)
        eq_(ctx['videos'].number, 2)
示例#4
0
    def test_valid_page(self):
        # Create more videos to get past 12
        for _ in range(12):
            VideoFactory.create(user=self.us_user, approved=True)

        response = self._video_list(page=2)
        eq_(response.context['videos'].number, 2)
示例#5
0
    def test_popular_sort(self):
        """If sort is 'popular', sort by the number of votes."""
        video_1 = VideoFactory.create(title='A', approved=True, vote_count=4)
        video_2 = VideoFactory.create(title='C', approved=True)
        video_3 = VideoFactory.create(title='B', approved=True, vote_count=7)

        eq_(list(search_videos(sort='popular')), [video_3, video_1, video_2])
示例#6
0
    def test_valid_page(self):
        # Create more videos to get past 12
        for _ in range(12):
            VideoFactory.create(user=self.us_user, approved=True)

        response = self._video_list(page=2)
        eq_(response.context['videos'].number, 2)
示例#7
0
    def test_valid_page(self):
        # Create more videos to get past 12
        for _ in range(14):
            VideoFactory.create(approved=True)

        ctx = self._video_list_ctx(page=2)
        eq_(ctx['videos'].number, 2)
    def test_title_sort(self):
        """If sort is 'title', sort videos alphabetically by their title."""
        video_1 = VideoFactory.create(title='A', approved=True)
        video_2 = VideoFactory.create(title='C', approved=True)
        video_3 = VideoFactory.create(title='B', approved=True)

        eq_(list(search_videos(sort='title')), [video_1, video_3, video_2])
    def test_random_sort(self):
        """By default, sort the videos by their random_ordering index."""
        video_1 = VideoFactory.create(random_ordering=3, approved=True)
        video_2 = VideoFactory.create(random_ordering=1, approved=True)
        video_3 = VideoFactory.create(random_ordering=2, approved=True)

        eq_(list(search_videos()), [video_2, video_3, video_1])
示例#10
0
    def test_empty_query(self):
        """If the search query has no terms, do not use it to filter videos."""
        v1 = VideoFactory.create(title='A', approved=True)
        v2 = VideoFactory.create(title='B', approved=True)

        eq_(set(search_videos(query='')), set([v1, v2]))
        eq_(set(search_videos(query='      ')), set([v1, v2]))
示例#11
0
    def test_title_sort(self):
        """By default, sort videos alphabetically by their title."""
        video_1 = VideoFactory.create(title='A', approved=True)
        video_2 = VideoFactory.create(title='C', approved=True)
        video_3 = VideoFactory.create(title='B', approved=True)

        eq_(list(search_videos()), [video_1, video_3, video_2])
示例#12
0
    def test_popular_sort(self):
        """If sort is 'popular', sort by the number of votes."""
        video_1 = VideoFactory.create(title="A", approved=True, vote_count=4)
        video_2 = VideoFactory.create(title="C", approved=True)
        video_3 = VideoFactory.create(title="B", approved=True, vote_count=7)

        eq_(list(search_videos(sort="popular")), [video_3, video_1, video_2])
示例#13
0
    def setUp(self):
        self.patch = patch("flicks.videos.search.search_videos")
        self.mock_search_videos = self.patch.start()

        self.v1 = VideoFactory.create(title="foo")
        self.v2 = VideoFactory.create(title="baz")
        self.mock_search_videos.return_value = Video.objects.filter(id__in=[self.v1.id, self.v2.id]).order_by("id")
示例#14
0
    def setUp(self):
        super(GalleryTests, self).setUp()
        self.us_user = UserProfileFactory.create(country='us').user
        self.fr_user = UserProfileFactory.create(country='fr').user

        self.v1 = VideoFactory.create(user=self.us_user, approved=True)
        self.v2 = VideoFactory.create(user=self.fr_user, approved=True)
示例#15
0
    def setUp(self):
        self.patch = patch('flicks.videos.search.search_videos')
        self.mock_search_videos = self.patch.start()

        self.v1 = VideoFactory.create(title='foo')
        self.v2 = VideoFactory.create(title='baz')
        self.mock_search_videos.return_value = Video.objects.filter(
            id__in=[self.v1.id, self.v2.id]).order_by('id')
示例#16
0
 def test_no_parameters(self):
     """
     If no parameters are passed, return a queryset of all approved videos.
     """
     VideoFactory.create(approved=False)
     v1 = VideoFactory.create(approved=True)
     v2 = VideoFactory.create(approved=True)
     eq_(list(search_videos()), [v1, v2])
示例#17
0
 def test_no_parameters(self):
     """
     If no parameters are passed, return a queryset of all approved videos.
     """
     VideoFactory.create(approved=False)
     v1 = VideoFactory.create(approved=True)
     v2 = VideoFactory.create(approved=True)
     eq_(list(search_videos()), [v1, v2])
示例#18
0
    def test_basic(self, MockVideo):
        v1 = VideoFactory.create()
        v2 = VideoFactory.create(random_ordering=5)
        v3 = VideoFactory.create()
        v4 = VideoFactory.create(random_ordering=3)
        MockVideo.objects.order_by.return_value = [v2, v3, v1, v4]

        update_random_video_ordering()
        eq_(list(Video.objects.order_by('random_ordering')), [v2, v3, v1, v4])
示例#19
0
    def test_query(self):
        """
        If a search query is given, the results should be limited to videos
        that contain any of the terms in their title, description, or user's
        full name.
        """
        VideoFactory.create(title='no match', approved=True)
        VideoFactory.create(description='no match', approved=True)
        user = UserProfileFactory.create(full_name='no match').user
        VideoFactory.create(user=user, approved=True)

        v1 = VideoFactory.create(title='A does match mytitle', approved=True)
        v2 = VideoFactory.create(title='B', description='does match mydesc',
                                 approved=True)
        user = UserProfileFactory.create(full_name='does match name').user
        v3 = VideoFactory.create(title='C', user=user, approved=True)

        eq_(set(search_videos(query='does')), set([v1, v2, v3]))

        # ANY term in the query can be used for matching.
        eq_(set(search_videos(query='what does bylaw')), set([v1, v2, v3]))

        # Search is case-insensitive.
        eq_(set(search_videos(query='DoEs')), set([v1, v2, v3]))

        # Terms may match only part of a word in the video.
        eq_(set(search_videos(query='floor do')), set([v1, v2, v3]))

        # Terms only have to match one of the three possible fields.
        eq_(set(search_videos(query='mytitle')), set([v1]))
        eq_(set(search_videos(query='mydesc')), set([v2]))
        eq_(set(search_videos(query='name')), set([v3]))
示例#20
0
    def test_query(self):
        """
        If a search query is given, the results should be limited to videos
        that contain any of the terms in their title, description, or user's
        full name.
        """
        VideoFactory.create(title='no match', approved=True)
        VideoFactory.create(description='no match', approved=True)
        user = UserProfileFactory.create(full_name='no match').user
        VideoFactory.create(user=user, approved=True)

        v1 = VideoFactory.create(title='A does match mytitle', approved=True)
        v2 = VideoFactory.create(title='B',
                                 description='does match mydesc',
                                 approved=True)
        user = UserProfileFactory.create(full_name='does match name').user
        v3 = VideoFactory.create(title='C', user=user, approved=True)

        eq_(list(search_videos(query='does')), [v1, v2, v3])

        # ANY term in the query can be used for matching.
        eq_(list(search_videos(query='what does bylaw')), [v1, v2, v3])

        # Search is case-insensitive.
        eq_(list(search_videos(query='DoEs')), [v1, v2, v3])

        # Terms may match only part of a word in the video.
        eq_(list(search_videos(query='floor do')), [v1, v2, v3])

        # Terms only have to match one of the three possible fields.
        eq_(list(search_videos(query='mytitle')), [v1])
        eq_(list(search_videos(query='mydesc')), [v2])
        eq_(list(search_videos(query='name')), [v3])
示例#21
0
    def test_query(self):
        """
        If a search query is given, the results should be limited to videos
        that contain any of the terms in their title, description, or user's
        full name.
        """
        VideoFactory.create(title="no match", approved=True)
        VideoFactory.create(description="no match", approved=True)
        user = UserProfileFactory.create(full_name="no match").user
        VideoFactory.create(user=user, approved=True)

        v1 = VideoFactory.create(title="A does match mytitle", approved=True)
        v2 = VideoFactory.create(title="B", description="does match mydesc", approved=True)
        user = UserProfileFactory.create(full_name="does match name").user
        v3 = VideoFactory.create(title="C", user=user, approved=True)

        eq_(list(search_videos(query="does")), [v1, v2, v3])

        # ANY term in the query can be used for matching.
        eq_(list(search_videos(query="what does bylaw")), [v1, v2, v3])

        # Search is case-insensitive.
        eq_(list(search_videos(query="DoEs")), [v1, v2, v3])

        # Terms may match only part of a word in the video.
        eq_(list(search_videos(query="floor do")), [v1, v2, v3])

        # Terms only have to match one of the three possible fields.
        eq_(list(search_videos(query="mytitle")), [v1])
        eq_(list(search_videos(query="mydesc")), [v2])
        eq_(list(search_videos(query="name")), [v3])
示例#22
0
    def test_invaid_region(self, get_countries):
        """If the given region is invalid, do not filter by it."""
        get_countries.return_value = None
        user_fr = UserProfileFactory.create(country="fr").user
        user_pt = UserProfileFactory.create(country="pt").user

        video_fr = VideoFactory.create(user=user_fr, approved=True)
        video_pt = VideoFactory.create(user=user_pt, approved=True)

        eq_(list(search_videos(region=1)), [video_fr, video_pt])
        get_countries.assert_called_with(1)
示例#23
0
    def test_invaid_region(self, get_countries):
        """If the given region is invalid, do not filter by it."""
        get_countries.return_value = None
        user_fr = UserProfileFactory.create(country='fr').user
        user_pt = UserProfileFactory.create(country='pt').user

        video_fr = VideoFactory.create(user=user_fr, approved=True)
        video_pt = VideoFactory.create(user=user_pt, approved=True)

        eq_(list(search_videos(region=1)), [video_fr, video_pt])
        get_countries.assert_called_with(1)
示例#24
0
    def test_fields(self):
        """
        If the fields parameter is specified, only perform a search on the
        fields specified in that list.
        """
        v1 = VideoFactory.create(title="foo", description="bar", approved=True)
        v2 = VideoFactory.create(title="bar", description="foo", approved=True)

        eq_(list(search_videos("foo", fields=["title"])), [v1])
        eq_(list(search_videos("bar", fields=["title"])), [v2])
        eq_(list(search_videos("bar", fields=["description"])), [v1])
        eq_(list(search_videos("bar", fields=["title", "description"])), [v2, v1])
示例#25
0
    def test_fields(self):
        """
        If the fields parameter is specified, only perform a search on the
        fields specified in that list.
        """
        v1 = VideoFactory.create(title='foo', description='bar', approved=True)
        v2 = VideoFactory.create(title='bar', description='foo', approved=True)

        eq_(list(search_videos('foo', fields=['title'])), [v1])
        eq_(list(search_videos('bar', fields=['title'])), [v2])
        eq_(list(search_videos('bar', fields=['description'])), [v1])
        eq_(list(search_videos('bar', fields=['title', 'description'])),
            [v2, v1])
示例#26
0
    def test_fields(self):
        """
        If the fields parameter is specified, only perform a search on the
        fields specified in that list.
        """
        v1 = VideoFactory.create(title='foo', description='bar', approved=True)
        v2 = VideoFactory.create(title='bar', description='foo', approved=True)

        eq_(set(search_videos('foo', fields=['title'])), set([v1]))
        eq_(set(search_videos('bar', fields=['title'])), set([v2]))
        eq_(set(search_videos('bar', fields=['description'])), set([v1]))
        videos = search_videos(
            'bar', fields=['title', 'description'], sort='title')
        eq_(set(videos), set([v2, v1]))
示例#27
0
    def test_region(self, get_countries):
        """
        If the region filter is given, only return videos from countries in
        that region.
        """
        get_countries.return_value = ["us", "fr"]
        user_fr = UserProfileFactory.create(country="fr").user
        user_pt = UserProfileFactory.create(country="pt").user

        video_fr = VideoFactory.create(user=user_fr, approved=True)
        VideoFactory.create(user=user_pt, approved=True)

        eq_(list(search_videos(region=1)), [video_fr])
        get_countries.assert_called_with(1)
示例#28
0
    def test_region(self, get_countries):
        """
        If the region filter is given, only return videos from countries in
        that region.
        """
        get_countries.return_value = ['us', 'fr']
        user_fr = UserProfileFactory.create(country='fr').user
        user_pt = UserProfileFactory.create(country='pt').user

        video_fr = VideoFactory.create(user=user_fr, approved=True)
        VideoFactory.create(user=user_pt, approved=True)

        eq_(list(search_videos(region=1)), [video_fr])
        get_countries.assert_called_with(1)
示例#29
0
    def test_empty(self, video_list):
        """
        If a user hasn't voted for any videos, my_voted_videos should be empty.
        """
        video_list.return_value = HttpResponse()

        user = UserFactory.create()
        for _ in range(14):
            VideoFactory.create(approved=True)

        response = self._my_voted_videos(user)
        eq_(response, video_list.return_value)

        videos = video_list.call_args[0][1]
        eq_(list(videos), [])
示例#30
0
    def test_empty(self, video_list):
        """
        If a user hasn't voted for any videos, my_voted_videos should be empty.
        """
        video_list.return_value = HttpResponse()

        user = UserFactory.create()
        for _ in range(14):
            VideoFactory.create(approved=True)

        response = self._my_voted_videos(user)
        eq_(response, video_list.return_value)

        videos = video_list.call_args[0][1]
        eq_(list(videos), [])
示例#31
0
    def test_valid_video(self, send_mail, mock_vimeo):
        """If a valid video id is given, update the Vimeo metadata."""
        # Many to many makes this super-verbose. Essentially, create two
        # moderators, one who is part of a moderator group and the other who
        # has the change_video2013 permission directly.
        perm = Permission.objects.get(codename='change_video2013')
        group = GroupFactory()
        group.permissions = [perm]
        group.save()
        moderator1 = UserFactory(email='*****@*****.**')
        moderator1.user_permissions = [perm]
        moderator1.save()
        moderator2 = UserFactory.create(email='*****@*****.**')
        moderator2.groups = [group]
        moderator2.save()

        user = UserProfileFactory.create(nickname='name', country='us').user
        video = VideoFactory.create(user=user, title='blah', description='asdf',
                                    vimeo_id=7)

        with self.settings(VIMEO_REGION_CHANNELS={regions.NORTH_AMERICA: 18},
                           DEFAULT_FROM_EMAIL='*****@*****.**'):
            process_video(video.id)

        mock_vimeo.set_title.assert_called_with(7, 'blah')
        mock_vimeo.set_description.assert_called_with(7, 'blah by name\n\nasdf')
        mock_vimeo.add_to_channel.assert_called_with(7, 18)
        mock_vimeo.add_tags.assert_called_with(7, ['us'])

        send_mail.assert_called_with(ANY, ANY, '*****@*****.**',
                                     CONTAINS('*****@*****.**',
                                              '*****@*****.**'))
示例#32
0
    def test_valid_video(self, send_mail, mock_vimeo):
        """If a valid video id is given, update the Vimeo metadata."""
        # Many to many makes this super-verbose. Essentially, create two
        # moderators, one who is part of a moderator group and the other who
        # has the change_video2013 permission directly.
        perm = Permission.objects.get(codename='change_video2013')
        group = GroupFactory()
        group.permissions = [perm]
        group.save()
        moderator1 = UserFactory(email='*****@*****.**')
        moderator1.user_permissions = [perm]
        moderator1.save()
        moderator2 = UserFactory.create(email='*****@*****.**')
        moderator2.groups = [group]
        moderator2.save()

        user = UserProfileFactory.create(nickname='name', country='us').user
        video = VideoFactory.create(user=user,
                                    title='blah',
                                    description='asdf',
                                    vimeo_id=7)

        with self.settings(VIMEO_REGION_CHANNELS={regions.NORTH_AMERICA: 18},
                           DEFAULT_FROM_EMAIL='*****@*****.**'):
            process_video(video.id)

        mock_vimeo.set_title.assert_called_with(7, 'blah')
        mock_vimeo.set_description.assert_called_with(7,
                                                      'blah by name\n\nasdf')
        mock_vimeo.add_to_channel.assert_called_with(7, 18)
        mock_vimeo.add_tags.assert_called_with(7, ['us'])

        send_mail.assert_called_with(
            ANY, ANY, '*****@*****.**',
            CONTAINS('*****@*****.**', '*****@*****.**'))
示例#33
0
    def test_no_vote(self):
        """If the user hasn't voted for the given video, return a 404."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()

        response = self._unvote_ajax(video.id)
        eq_(response.status_code, 404)
示例#34
0
    def test_no_vote(self):
        """If the user hasn't voted for the given video, return a 404."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()

        response = self._unvote_ajax(video.id)
        eq_(response.status_code, 404)
示例#35
0
    def test_invalid_page(self):
        """
        Invalid or missing page numbers default to the first page. Pages beyond
        the last page go to the last page.
        """
        response = self._video_list(page='asdf')
        eq_(response.context['videos'].number, 1)

        response = self._video_list(page=-1)
        eq_(response.context['videos'].number, 1)

        # Create more videos to get past 12
        for _ in range(12):
            VideoFactory.create(user=self.us_user, approved=True)

        # Pages beyond the max go to the last page
        response = self._video_list(page=5555)
        eq_(response.context['videos'].number, 2)
示例#36
0
    def test_invalid_page(self):
        """
        Invalid or missing page numbers default to the first page. Pages beyond
        the last page go to the last page.
        """
        response = self._video_list(page='asdf')
        eq_(response.context['videos'].number, 1)

        response = self._video_list(page=-1)
        eq_(response.context['videos'].number, 1)

        # Create more videos to get past 12
        for _ in range(12):
            VideoFactory.create(user=self.us_user, approved=True)

        # Pages beyond the max go to the last page
        response = self._video_list(page=5555)
        eq_(response.context['videos'].number, 2)
示例#37
0
    def test_vote_exists(self):
        """If the user has voted for the given video, delete the vote."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()
        Vote.objects.create(user=user, video=video)

        response = self._unvote_ajax(video.id)
        eq_(response.status_code, 200)
        ok_(not Vote.objects.filter(user=user, video=video).exists())
示例#38
0
    def test_vote_exists(self):
        """If the user has voted for the given video, delete the vote."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()
        Vote.objects.create(user=user, video=video)

        response = self._unvote_ajax(video.id)
        eq_(response.status_code, 200)
        ok_(not Vote.objects.filter(user=user, video=video).exists())
示例#39
0
    def test_basic(self, video_list):
        """
        my_voted_videos should list all the videos a user has voted for in the
        reverse order that they voted for them.
        """
        video_list.return_value = HttpResponse()

        user = UserFactory.create()
        v1 = VideoFactory.create(approved=True)
        v2 = VideoFactory.create(approved=True)
        Vote.objects.create(user=user, video=v1)
        Vote.objects.create(user=user, video=v2)
        for _ in range(14):
            VideoFactory.create(approved=True)

        response = self._my_voted_videos(user)
        eq_(response, video_list.return_value)

        videos = video_list.call_args[0][1]
        eq_(list(videos), [v2, v1])  # Also asserts the order of the votes.
示例#40
0
    def test_login_success_no_vote(self, mock_super):
        """
        If the user hasn't voted for the video, create a vote for it and remove
        the session key.
        """
        video = VideoFactory.create()
        self.request.session['vote_video'] = unicode(video.id)

        self.verify.login_success()
        ok_('vote_video' not in self.request.session)
        eq_(Vote.objects.filter(user=self.user, video=video).count(), 1)
示例#41
0
 def test_no_profile(self, use_lang):
     """
     If the user has no profile, use the installation's default language
     code for the email locale.
     """
     user = UserFactory.create(email='*****@*****.**')
     video = VideoFactory.create(user=user)
     send_approval_email(video)
     eq_(len(mail.outbox), 1)
     eq_(mail.outbox[0].to, ['*****@*****.**'])
     use_lang.assert_called_with('fr')
示例#42
0
    def test_login_success_no_vote(self, mock_super):
        """
        If the user hasn't voted for the video, create a vote for it and remove
        the session key.
        """
        video = VideoFactory.create()
        self.request.session['vote_video'] = unicode(video.id)

        self.verify.login_success()
        ok_('vote_video' not in self.request.session)
        eq_(Vote.objects.filter(user=self.user, video=video).count(), 1)
示例#43
0
    def test_basic(self, video_list):
        """
        my_voted_videos should list all the videos a user has voted for in the
        reverse order that they voted for them.
        """
        video_list.return_value = HttpResponse()

        user = UserFactory.create()
        v1 = VideoFactory.create(approved=True)
        v2 = VideoFactory.create(approved=True)
        Vote.objects.create(user=user, video=v1)
        Vote.objects.create(user=user, video=v2)
        for _ in range(14):
            VideoFactory.create(approved=True)

        response = self._my_voted_videos(user)
        eq_(response, video_list.return_value)

        videos = video_list.call_args[0][1]
        eq_(list(videos), [v2, v1])  # Also asserts the order of the votes.
示例#44
0
    def test_login_success_vote_exists(self, mock_super):
        """
        If the user has already voted for the video, remove the session key and
        do nothing.
        """
        video = VideoFactory.create()
        Vote.objects.create(user=self.user, video=video)
        self.request.session['vote_video'] = unicode(video.id)

        self.verify.login_success()
        ok_('vote_video' not in self.request.session)
        eq_(Vote.objects.filter(user=self.user, video=video).count(), 1)
示例#45
0
    def test_login_success_vote_exists(self, mock_super):
        """
        If the user has already voted for the video, remove the session key and
        do nothing.
        """
        video = VideoFactory.create()
        Vote.objects.create(user=self.user, video=video)
        self.request.session['vote_video'] = unicode(video.id)

        self.verify.login_success()
        ok_('vote_video' not in self.request.session)
        eq_(Vote.objects.filter(user=self.user, video=video).count(), 1)
示例#46
0
    def test_authed_user_video_exists(self):
        """If the user is authed and the video exists, add a vote for it."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()

        response = self._vote_ajax(video.id)
        eq_(response.status_code, 200)
        ok_(Vote.objects.filter(user=user, video=video).exists())

        # If the vote already exists, don't add a new one.
        response = self._vote_ajax(video.id)
        eq_(response.status_code, 200)
        eq_(Vote.objects.filter(user=user, video=video).count(), 1)
示例#47
0
    def test_authed_user_video_exists(self):
        """If the user is authed and the video exists, add a vote for it."""
        user = UserFactory.create()
        self.browserid_login(user.email)
        video = VideoFactory.create()

        response = self._vote_ajax(video.id)
        eq_(response.status_code, 200)
        ok_(Vote.objects.filter(user=user, video=video).exists())

        # If the vote already exists, don't add a new one.
        response = self._vote_ajax(video.id)
        eq_(response.status_code, 200)
        eq_(Vote.objects.filter(user=user, video=video).count(), 1)
示例#48
0
    def test_invalid_page(self):
        """
        Invalid or missing page numbers default to the first page. Pages beyond
        the last page or negative pages go to the last page.
        """
        for _ in range(30):
            VideoFactory.create(approved=True)

        ctx = self._video_list_ctx(page=1)
        eq_(ctx['videos'].number, 1)

        ctx = self._video_list_ctx(page=-1)
        eq_(ctx['videos'].number, 3)

        ctx = self._video_list_ctx(page='asdf')
        eq_(ctx['videos'].number, 1)

        ctx = self._video_list_ctx()
        eq_(ctx['videos'].number, 1)

        # Pages beyond the max go to the last page
        ctx = self._video_list_ctx(page=5555)
        eq_(ctx['videos'].number, 3)
示例#49
0
    def test_invalid_page(self):
        """
        Invalid or missing page numbers default to the first page. Pages beyond
        the last page or negative pages go to the last page.
        """
        for _ in range(30):
            VideoFactory.create(approved=True)

        ctx = self._video_list_ctx(page=1)
        eq_(ctx['videos'].number, 1)

        ctx = self._video_list_ctx(page=-1)
        eq_(ctx['videos'].number, 3)

        ctx = self._video_list_ctx(page='asdf')
        eq_(ctx['videos'].number, 1)

        ctx = self._video_list_ctx()
        eq_(ctx['videos'].number, 1)

        # Pages beyond the max go to the last page
        ctx = self._video_list_ctx(page=5555)
        eq_(ctx['videos'].number, 3)
示例#50
0
    def setUp(self):
        self.patch = patch('flicks.videos.search.search_videos')
        self.mock_search_videos = self.patch.start()

        self.v1 = VideoFactory.create(title='foo', description='bar')
        self.v2 = VideoFactory.create(title='baz', description='biff')
示例#51
0
 def test_basic(self):
     user = UserProfileFactory.create(user__email='*****@*****.**').user
     video = VideoFactory.create(user=user)
     send_approval_email(video)
     eq_(len(mail.outbox), 1)
     eq_(mail.outbox[0].to, ['*****@*****.**'])