Commits

Chris Grubbs committed 5fdf32a

more testing

Comments (0)

Files changed (5)

phlombay/recipes/fixtures/auth_user.json

             "last_login": "2012-09-22T15:10:17.710",
             "groups": [ ],
             "user_permissions": [ ],
-            "password": "pbkdf2_sha256$10000$hH8EfAdXp1K9$G4niugQHbzyG6+VmWIP43AXBwThGD5rcrmgD0h2blsk=",
+            "password": "pbkdf2_sha256$10000$BZ55qlUOlaOA$0Av1AnEC1xEqwonjJZlVsaufBU8JeHtECklx96w8z2w=",
             "email": "user1@test.com",
             "date_joined": "2012-09-22T10:54:12"
         }
             "last_login": "2012-09-22T22:18:01.604",
             "groups": [ ],
             "user_permissions": [ ],
-            "password": "pbkdf2_sha256$10000$Rw4ZBuCMptZZ$kIByqtCJxWgoqYLfRhoRYE15YQmLE3FTTlJhJOrhMnc=",
+            "password": "pbkdf2_sha256$10000$BZ55qlUOlaOA$0Av1AnEC1xEqwonjJZlVsaufBU8JeHtECklx96w8z2w=",
             "email": "user2@test.com",
             "date_joined": "2012-09-22T15:07:36"
         }

phlombay/recipes/tests.py

         response = self.client.get('/recipes/detail/1/')
         self.assertTemplateUsed(response, 'recipes/detail.html')
         self.assertContains(response, 'Prosciutto & Melon Bites')
+
+    def test_login(self):
+        response = self.client.get('/recipes/login/')
+        self.assertTemplateUsed(response, 'recipes/login.html')
+        
+    def test_successful_login(self):
+        response = self.client.post('/recipes/login/', {'username': 'user2', 'password': 'secret'})
+        self.assertRedirects(response, '/recipes/my-page/')
+
+    def test_unsuccessful_login(self):
+        response = self.client.post('/recipes/login/', {'username': '', 'password': 'foo'})
+        self.assertFormError(response, 'auth_form', 'username', u'This field is required.')
+
+        response = self.client.post('/recipes/login/', {'username': 'user2', 'password': ''})
+        self.assertFormError(response, 'auth_form', 'password', u'This field is required.')
+
+        response = self.client.post('/recipes/login/', {'username': 'user2', 'password': 'nope'})
+        self.assertTemplateUsed(response, 'recipes/login.html')
+        self.assertContains(response, 'Please enter a correct username and password. Note that both fields are case-sensitive.')
+
+    def test_my_page(self):
+        self.client.login(username='user2', password='secret')
+        response = self.client.get('/recipes/my-page/')
+        self.assertTemplateUsed(response, 'recipes/my_page.html')
+
+    def test_my_page_not_logged_in(self):
+        response = self.client.get('/recipes/my-page/')
+        self.assertRedirects(response, '/recipes/login/?next=/recipes/my-page/')

phlombay/settings_base.py

     'django.contrib.staticfiles',
     'phlombay.recipes',
 )
+
+LOGIN_URL = '/recipes/login/'

phlombay/templates/404.html

+{% extends "base.html" %}
+
+{% block title %}Sorry, that page was not found | phlombay.com{% endblock %}
+
+{% block content %}
+	<h1>Missing Ingredients!</h1>
+	
+	<p>Sorry, that page was not found.</p>
+{% endblock %}
+
+
+

phlombay/templates/500.html

+{% extends "base.html" %}
+
+{% block title %}Sorry, there was an error | phlombay.com{% endblock %}
+
+{% block content %}
+	<h1>Kitchen Disaster!</h1>
+	
+	<p>Sorry, there was an error.</p>
+{% endblock %}
+
+
+