Commit e1ab2c19ee334b90a8b04bed2e25657945be4471
1 parent
bf3dfc25
Exists in
master
and in
5 other branches
Test register ok #5
Showing
1 changed file
with
11 additions
and
5 deletions
Show diff stats
core/tests.py
1 | from django.test import TestCase, Client | 1 | from django.test import TestCase, Client |
2 | from django.core.urlresolvers import reverse | 2 | from django.core.urlresolvers import reverse |
3 | +from django.utils.translation import ugettext_lazy as _ | ||
3 | from rolepermissions.shortcuts import assign_role | 4 | from rolepermissions.shortcuts import assign_role |
4 | from users.models import User | 5 | from users.models import User |
5 | from django.core import mail | 6 | from django.core import mail |
@@ -44,9 +45,11 @@ class RegisterUserTestCase(TestCase): | @@ -44,9 +45,11 @@ class RegisterUserTestCase(TestCase): | ||
44 | self.url = reverse('core:register') | 45 | self.url = reverse('core:register') |
45 | self.data = { | 46 | self.data = { |
46 | 'username': 'testeamadeus', | 47 | 'username': 'testeamadeus', |
48 | + 'birth_date': '12/12/2000', | ||
47 | 'email': 'teste@amadeus.com', | 49 | 'email': 'teste@amadeus.com', |
48 | 'password': 'aminhasenha1', | 50 | 'password': 'aminhasenha1', |
49 | 'password2': 'aminhasenha1', | 51 | 'password2': 'aminhasenha1', |
52 | + 'cpf': '705.089.884-89', | ||
50 | 'name': 'Teste Amadeus', | 53 | 'name': 'Teste Amadeus', |
51 | 'city': 'Praia', | 54 | 'city': 'Praia', |
52 | 'state': 'PE', | 55 | 'state': 'PE', |
@@ -55,9 +58,9 @@ class RegisterUserTestCase(TestCase): | @@ -55,9 +58,9 @@ class RegisterUserTestCase(TestCase): | ||
55 | 58 | ||
56 | def test_register_ok(self): | 59 | def test_register_ok(self): |
57 | 60 | ||
58 | - response = self.client.post(self.url, self.data) | ||
59 | - self.assertRedirects(response, 'http://localhost%s' % reverse('core:home')) | ||
60 | - self.assertEqual(response.status_code, 302) | 61 | + response = self.client.post(self.url, self.data, follow=True) |
62 | + self.assertRedirects(response, reverse('core:home')) | ||
63 | + self.assertEqual(response.status_code, 200) | ||
61 | self.assertEqual(User.objects.count(), 1) | 64 | self.assertEqual(User.objects.count(), 1) |
62 | 65 | ||
63 | def test_register_error(self): | 66 | def test_register_error(self): |
@@ -66,6 +69,7 @@ class RegisterUserTestCase(TestCase): | @@ -66,6 +69,7 @@ class RegisterUserTestCase(TestCase): | ||
66 | 69 | ||
67 | data = { | 70 | data = { |
68 | 'username': 'testeamadeus', | 71 | 'username': 'testeamadeus', |
72 | + 'birth_date': '12/12/2000', | ||
69 | 'email': 'teste@amadeus.com', | 73 | 'email': 'teste@amadeus.com', |
70 | 'password': 'aminhasenha1', | 74 | 'password': 'aminhasenha1', |
71 | 'password2': 'aminhasenha', | 75 | 'password2': 'aminhasenha', |
@@ -80,6 +84,7 @@ class RegisterUserTestCase(TestCase): | @@ -80,6 +84,7 @@ class RegisterUserTestCase(TestCase): | ||
80 | data = { | 84 | data = { |
81 | 'username': 'testeamadeus', | 85 | 'username': 'testeamadeus', |
82 | 'email': 'teste.amadeus.com', | 86 | 'email': 'teste.amadeus.com', |
87 | + 'birth_date': '12/12/2000', | ||
83 | 'password': 'aminhasenha1', | 88 | 'password': 'aminhasenha1', |
84 | 'password2': 'aminhasenha', | 89 | 'password2': 'aminhasenha', |
85 | 'name': 'Teste Amadeus', | 90 | 'name': 'Teste Amadeus', |
@@ -89,11 +94,12 @@ class RegisterUserTestCase(TestCase): | @@ -89,11 +94,12 @@ class RegisterUserTestCase(TestCase): | ||
89 | } | 94 | } |
90 | 95 | ||
91 | response = self.client.post(self.url, data) | 96 | response = self.client.post(self.url, data) |
92 | - self.assertFormError(response, 'form', 'email', 'Enter a valid email address.') | 97 | + self.assertFormError(response, 'form', 'email', _('Enter a valid email address.')) |
93 | 98 | ||
94 | data = { | 99 | data = { |
95 | 'username': '', | 100 | 'username': '', |
96 | 'email': 'teste@amadeus.com', | 101 | 'email': 'teste@amadeus.com', |
102 | + 'birth_date': '12/12/2000', | ||
97 | 'password': 'aminhasenha1', | 103 | 'password': 'aminhasenha1', |
98 | 'password2': 'aminhasenha', | 104 | 'password2': 'aminhasenha', |
99 | 'name': 'Teste Amadeus', | 105 | 'name': 'Teste Amadeus', |
@@ -102,7 +108,7 @@ class RegisterUserTestCase(TestCase): | @@ -102,7 +108,7 @@ class RegisterUserTestCase(TestCase): | ||
102 | 'gender': 'F', | 108 | 'gender': 'F', |
103 | } | 109 | } |
104 | response = self.client.post(self.url, data) | 110 | response = self.client.post(self.url, data) |
105 | - self.assertFormError(response, 'form', 'username', 'This field is required.') | 111 | + self.assertFormError(response, 'form', 'username', _('This field is required.')) |
106 | 112 | ||
107 | class RememberPasswordTestCase(TestCase): | 113 | class RememberPasswordTestCase(TestCase): |
108 | 114 |