def test_post_valid(self):
     """
     If POSTed with valid values, create a profile and redirect to
     flicks.videos.upload.
     """
     response = self._profile('post', locale='fr', full_name='blah',
                              nickname='blah', country='fr',
                              privacy_policy_agree=True)
     redirects_(response, 'flicks.videos.upload', locale='fr')
     ok_(UserProfile.objects.filter(user=self.user).exists())
     eq_(UserProfile.objects.get(user=self.user).locale, 'fr')
    def test_no_profile(self):
        """
        If the user has no profile, return a redirect to flicks.users.profile.
        """
        @profile_required
        def view(request):
            return HttpResponse('asdf')

        request = self.factory.get('/someurl')
        request.user = UserFactory()
        response = view(request)
        redirects_(response, 'flicks.users.profile')
Beispiel #3
0
 def test_post_valid(self):
     """
     If POSTed with valid values, create a profile and redirect to
     flicks.videos.upload.
     """
     response = self._profile('post',
                              locale='fr',
                              full_name='blah',
                              nickname='blah',
                              country='fr',
                              privacy_policy_agree=True)
     redirects_(response, 'flicks.videos.upload', locale='fr')
     ok_(UserProfile.objects.filter(user=self.user).exists())
     eq_(UserProfile.objects.get(user=self.user).locale, 'fr')
    def test_no_user_with_login_url(self):
        """
        If the given request has no logged-in user, return a redirect to the
        given login_url.
        """
        @profile_required(login_url='/test/url2')
        def view(request):
            return HttpResponse('asdf')

        request = self.factory.get('/someurl')
        request.user = AnonymousUser()
        with self.settings(LOGIN_URL='/test/url'):
            response = view(request)
            redirects_(response, '/test/url2?next=/someurl')
    def test_post_success(self, vimeo, process_video):
        """
        If a valid form is POSTed and the upload checks out, create a new video,
        remove the upload ticket from the session, and return a redirect to the
        upload complete page.
        """

        vimeo.verify_chunks.return_value = True
        vimeo.complete_upload.return_value = {'video_id': '563'}
        response = self._upload('post', ticket={'id': 'asdf'}, title='qwer',
                                filename='qwer.mp4', filesize=5)

        vimeo.complete_upload.assert_called_with('asdf', 'qwer.mp4')
        videos = Video.objects.filter(title='qwer', filename='qwer.mp4',
                                      vimeo_id=563, user=self.user)
        eq_(len(videos), 1)
        process_video.delay.assert_called_with(videos[0].id)
        ok_('vimeo_id' not in response.client.session)
        redirects_(response, 'flicks.videos.upload_complete')
Beispiel #6
0
    def test_post_success(self, vimeo, process_video):
        """
        If a valid form is POSTed and the upload checks out, create a new video,
        remove the upload ticket from the session, and return a redirect to the
        upload complete page.
        """

        vimeo.verify_chunks.return_value = True
        vimeo.complete_upload.return_value = {'video_id': '563'}
        response = self._upload('post',
                                ticket={'id': 'asdf'},
                                title='qwer',
                                filename='qwer.mp4',
                                filesize=5)

        vimeo.complete_upload.assert_called_with('asdf', 'qwer.mp4')
        videos = Video.objects.filter(title='qwer',
                                      filename='qwer.mp4',
                                      vimeo_id=563,
                                      user=self.user)
        eq_(len(videos), 1)
        process_video.delay.assert_called_with(videos[0].id)
        ok_('vimeo_id' not in response.client.session)
        redirects_(response, 'flicks.videos.upload_complete')