Commit 64e8f5873f728891d43d130f41396d27f34148fd
1 parent
5f579329
Exists in
master
and in
5 other branches
Test register_user_ok ##5
Showing
2 changed files
with
8 additions
and
8 deletions
Show diff stats
core/forms.py
@@ -6,7 +6,7 @@ class RegisterUserForm(forms.ModelForm): | @@ -6,7 +6,7 @@ class RegisterUserForm(forms.ModelForm): | ||
6 | 6 | ||
7 | password = forms.CharField(label='Senha', widget=forms.PasswordInput) | 7 | password = forms.CharField(label='Senha', widget=forms.PasswordInput) |
8 | password2 = forms.CharField(label = 'Confirmacao de Senha', widget = forms.PasswordInput) | 8 | password2 = forms.CharField(label = 'Confirmacao de Senha', widget = forms.PasswordInput) |
9 | - birth_date = forms.DateField(widget=forms.SelectDateWidget()) | 9 | + # birth_date = forms.DateField(widget=forms.SelectDateWidget()) |
10 | MIN_LENGTH = 8 | 10 | MIN_LENGTH = 8 |
11 | 11 | ||
12 | def clean_password(self): | 12 | def clean_password(self): |
@@ -42,4 +42,4 @@ class RegisterUserForm(forms.ModelForm): | @@ -42,4 +42,4 @@ class RegisterUserForm(forms.ModelForm): | ||
42 | class Meta: | 42 | class Meta: |
43 | model = User | 43 | model = User |
44 | # exclude = ['is_staff', 'is_active'] | 44 | # exclude = ['is_staff', 'is_active'] |
45 | - fields = ['username', 'name', 'email', 'city', 'state', 'gender', 'cpf', 'phone', 'image'] | ||
46 | \ No newline at end of file | 45 | \ No newline at end of file |
46 | + fields = ['username', 'name', 'email', 'city', 'state', 'gender', 'cpf', 'birth_date', 'phone', 'image'] | ||
47 | \ No newline at end of file | 47 | \ No newline at end of file |
core/tests.py
@@ -42,11 +42,7 @@ class RegisterUserTestCase(TestCase): | @@ -42,11 +42,7 @@ class RegisterUserTestCase(TestCase): | ||
42 | def setUp(self): | 42 | def setUp(self): |
43 | self.client = Client() | 43 | self.client = Client() |
44 | self.url = reverse('core:register') | 44 | self.url = reverse('core:register') |
45 | - | ||
46 | - def test_register_ok(self): | ||
47 | - | ||
48 | - response = self.client.post(self.url, | ||
49 | - data={ | 45 | + self.data = { |
50 | 'username': 'testeamadeus', | 46 | 'username': 'testeamadeus', |
51 | 'email': 'teste@amadeus.com', | 47 | 'email': 'teste@amadeus.com', |
52 | 'password': 'aminhasenha1', | 48 | 'password': 'aminhasenha1', |
@@ -55,7 +51,11 @@ class RegisterUserTestCase(TestCase): | @@ -55,7 +51,11 @@ class RegisterUserTestCase(TestCase): | ||
55 | 'city': 'Praia', | 51 | 'city': 'Praia', |
56 | 'state': 'PE', | 52 | 'state': 'PE', |
57 | 'gender': 'F', | 53 | 'gender': 'F', |
58 | - }) | 54 | + } |
55 | + | ||
56 | + def test_register_ok(self): | ||
57 | + | ||
58 | + response = self.client.post(self.url, self.data) | ||
59 | self.assertRedirects(response, 'http://localhost%s' % reverse('core:home')) | 59 | self.assertRedirects(response, 'http://localhost%s' % reverse('core:home')) |
60 | self.assertEqual(response.status_code, 302) | 60 | self.assertEqual(response.status_code, 302) |
61 | self.assertEqual(User.objects.count(), 1) | 61 | self.assertEqual(User.objects.count(), 1) |