Пример #1
0
class UsernameTestCase(TestCase):
    def setUp(self):
        self.client = Client()
        self.existing_username = "******"
        create_example_user()
        create_example_user(self.existing_username, "*****@*****.**", "password")
        login(self)

    def test_existing_username(self):
        """The username view should return "true" when the
            username exists.
            """
        response = self.client.get(reverse('users:username'),
                                   {'username': self.existing_username})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, "true")

    def test_new_username(self):
        """The username view should return "false" when the username
            doesn't exist.
            """
        response = self.client.get(reverse('users:username'),
                                   {'username': '******'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, "false")

    def test_no_input(self):
        """The username view should return nothing if no input
            is specified.
            """
        response = self.client.get(reverse('users:username'), {})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, "")
Пример #2
0
class UsernameTestCase(TestCase):
        def setUp(self):
            self.client = Client()
            self.existing_username = "******"
            create_example_user()
            create_example_user(self.existing_username, "*****@*****.**", "password")
            login(self)
            
        def test_existing_username(self):
            """The username view should return "true" when the
            username exists.
            """
            response = self.client.get(
                reverse('users:username'),
                {'username':self.existing_username}
            )
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.content, "true")
            
        def test_new_username(self):
            """The username view should return "false" when the username
            doesn't exist.
            """
            response = self.client.get(
                reverse('users:username'),
                {'username':'******'}
            )
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.content, "false")
            
        def test_no_input(self):
            """The username view should return nothing if no input
            is specified.
            """
            response = self.client.get(reverse('users:username'), {})
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.content, "")
Пример #3
0
 def test_homepage_to_login_redirect(self):
     client = Client()
     response = client.get(reverse('home'), follow=True)
     self.assertTrue(response.redirect_chain[0][0].endswith(reverse('django.contrib.auth.views.login')))
     self.assertEqual(response.redirect_chain[0][1], 302)
     self.assertEqual(response.status_code, 200)
Пример #4
0
 def test_admin_disabled(self):
     client = Client()
     response = client.get('/admin/')
     self.assertEqual(response.status_code, 404)
 def test_homepage_to_login_redirect(self):
     client = Client()
     response = client.get(reverse('home'), follow=True)
     self.assertEqual(response.status_code, 200)
     self.assertTemplateUsed(response, 'home.html')
 def test_admin_disabled(self):
     client = Client()
     response = client.get('/admin/')
     self.assertEqual(response.status_code, 404)
Пример #7
0
 def test_homepage_to_login_redirect(self):
     client = Client()
     response = client.get(reverse("home"), follow=True)
     self.assertEqual(response.status_code, 200)
     self.assertTemplateUsed(response, "home.html")
Пример #8
0
 def test_404_page(self):
     client = Client()
     response = client.get(reverse('home') + 'thisurldoesnotexist')
     self.assertEqual(response.status_code, 404)
     self.assertTemplateUsed(response, '404.html')
     self.assertTrue('rattic_icon' in response.context.keys())