Ejemplo n.º 1
0
    def test_contact_redirect(self):
        request = self.request_factory.get('/contact')
        request.user = AnonymousUser()
        service = AppRedirectionService()

        self.assertEqual('https://welcome.astrobin.com/contact',
                         service.contact_redirect(request))
    def test_contact_redirect_with_user(self):
        request = self.request_factory.get('/contact')
        request.user = Generators.user()
        service = AppRedirectionService()

        url = service.contact_redirect(request)

        self.assertTrue('username=%s' % urllib.quote(request.user.username) in url)
        self.assertTrue('email=%s' % urllib.quote(request.user.email) in url)
Ejemplo n.º 3
0
    def test_contact_redirect_with_request_data(self):
        request = self.request_factory.get('/contact')
        request.user = AnonymousUser()
        request.GET = {'subject': 'foo', 'message': 'bar'}
        service = AppRedirectionService()

        url = service.contact_redirect(request)

        self.assertTrue('subject=foo' in url)
        self.assertTrue('message=bar' in url)
Ejemplo n.º 4
0
    def test_contact_redirect_with_user_and_request_data(self):
        request = self.request_factory.get('/contact')
        request.user = Generators.user()
        request.GET = {'subject': 'foo', 'message': 'bar'}
        service = AppRedirectionService()

        url = service.contact_redirect(request)

        self.assertTrue('username=%s' %
                        urllib.parse.quote(request.user.username) in url)
        self.assertTrue('email=%s' %
                        urllib.parse.quote(request.user.email) in url)
        self.assertTrue('subject=foo' in url)
        self.assertTrue('message=bar' in url)
Ejemplo n.º 5
0
    def test_contact_redirect_with_user_with_non_ascii_username(self):
        request = self.request_factory.get('/contact')

        user = Generators.user()
        user.username = '******'
        user.save()

        request.user = user

        service = AppRedirectionService()

        url = service.contact_redirect(request)

        self.assertTrue(
            'username=%s' %
            urllib.parse.quote(str(request.user.username).encode('utf-8')) in
            url)
        self.assertTrue('email=%s' %
                        urllib.parse.quote(request.user.email) in url)
Ejemplo n.º 6
0
 def get_redirect_url(self, *args, **kwargs):
     return AppRedirectionService.contact_redirect(self.request)