1. fcoelho
  2. django-signup

Commits

fcoelho  committed 53ca117

tests for POST postconditions

  • Participants
  • Parent commits 20d5192
  • Branches default

Comments (0)

Files changed (1)

File signup/tests/test_views.py

View file
+from django import forms
+from django.contrib.auth import get_user_model
 from django.core.urlresolvers import reverse
 from django.test import TestCase
-from django import forms
 from django.test.utils import override_settings
 
 from signup.forms import DefaultUserCreationForm
 from signup.views import SignUpView
+from signup.models import Validation
 
 class AlternateSignupForm(forms.Form):
 	pass
 		self.assertEquals(r.status_code, 200)
 		self.assertTemplateUsed(r, 'registration/signup_complete.html')
 
+class SignupPostTests(TestCase):
+	def setUp(self):
+		url = reverse('signup_signup')
+		r = self.client.post(url, {
+			'username': 'alice',
+			'email': 'alice@bob.com',
+			'password1': 'alicepass',
+			'password2': 'alicepass'
+		})
+		self.assertRedirects(r, reverse('signup_signup_complete'))
+
+	def test_instance_created(self):
+		self.assertEquals(Validation.objects.count(), 1)
+
+	def test_user_created(self):
+		User = get_user_model()
+		u = User.objects.get(username='alice')
+
+	def test_validation_exists(self):
+		User = get_user_model()
+		u = User.objects.get(username='alice')
+
+		Validation.objects.get(user=u)
+
+	def test_user_is_not_activated(self):
+		User = get_user_model()
+		u = User.objects.get(username='alice')
+
+		self.assertFalse(u.is_active)
+