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 | 1 | from django.test import TestCase, Client |
| 2 | 2 | from django.core.urlresolvers import reverse |
| 3 | +from django.utils.translation import ugettext_lazy as _ | |
| 3 | 4 | from rolepermissions.shortcuts import assign_role |
| 4 | 5 | from users.models import User |
| 5 | 6 | from django.core import mail |
| ... | ... | @@ -44,9 +45,11 @@ class RegisterUserTestCase(TestCase): |
| 44 | 45 | self.url = reverse('core:register') |
| 45 | 46 | self.data = { |
| 46 | 47 | 'username': 'testeamadeus', |
| 48 | + 'birth_date': '12/12/2000', | |
| 47 | 49 | 'email': 'teste@amadeus.com', |
| 48 | 50 | 'password': 'aminhasenha1', |
| 49 | 51 | 'password2': 'aminhasenha1', |
| 52 | + 'cpf': '705.089.884-89', | |
| 50 | 53 | 'name': 'Teste Amadeus', |
| 51 | 54 | 'city': 'Praia', |
| 52 | 55 | 'state': 'PE', |
| ... | ... | @@ -55,9 +58,9 @@ class RegisterUserTestCase(TestCase): |
| 55 | 58 | |
| 56 | 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 | 64 | self.assertEqual(User.objects.count(), 1) |
| 62 | 65 | |
| 63 | 66 | def test_register_error(self): |
| ... | ... | @@ -66,6 +69,7 @@ class RegisterUserTestCase(TestCase): |
| 66 | 69 | |
| 67 | 70 | data = { |
| 68 | 71 | 'username': 'testeamadeus', |
| 72 | + 'birth_date': '12/12/2000', | |
| 69 | 73 | 'email': 'teste@amadeus.com', |
| 70 | 74 | 'password': 'aminhasenha1', |
| 71 | 75 | 'password2': 'aminhasenha', |
| ... | ... | @@ -80,6 +84,7 @@ class RegisterUserTestCase(TestCase): |
| 80 | 84 | data = { |
| 81 | 85 | 'username': 'testeamadeus', |
| 82 | 86 | 'email': 'teste.amadeus.com', |
| 87 | + 'birth_date': '12/12/2000', | |
| 83 | 88 | 'password': 'aminhasenha1', |
| 84 | 89 | 'password2': 'aminhasenha', |
| 85 | 90 | 'name': 'Teste Amadeus', |
| ... | ... | @@ -89,11 +94,12 @@ class RegisterUserTestCase(TestCase): |
| 89 | 94 | } |
| 90 | 95 | |
| 91 | 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 | 99 | data = { |
| 95 | 100 | 'username': '', |
| 96 | 101 | 'email': 'teste@amadeus.com', |
| 102 | + 'birth_date': '12/12/2000', | |
| 97 | 103 | 'password': 'aminhasenha1', |
| 98 | 104 | 'password2': 'aminhasenha', |
| 99 | 105 | 'name': 'Teste Amadeus', |
| ... | ... | @@ -102,7 +108,7 @@ class RegisterUserTestCase(TestCase): |
| 102 | 108 | 'gender': 'F', |
| 103 | 109 | } |
| 104 | 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 | 113 | class RememberPasswordTestCase(TestCase): |
| 108 | 114 | ... | ... |