Commit 4bfc00106155229e7f444ede009c727491842fbe
Committed by
Sergio Oliveira
1 parent
c988cf2c
Exists in
master
and in
33 other branches
Loggin upon existing email done.
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Signed-off-by: Matheus Fernandes <matheus.souza.fernandes@gmail.com> Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
Showing
2 changed files
with
49 additions
and
2 deletions
Show diff stats
colab/accounts/forms.py
... | ... | @@ -46,10 +46,10 @@ class UserForm(forms.ModelForm): |
46 | 46 | # Forces username to be lowercase always |
47 | 47 | widget=forms.TextInput(attrs={'style': 'text-transform: lowercase;'}), |
48 | 48 | ) |
49 | - required = ('first_name', 'last_name', 'username') | |
49 | + required = ('first_name', 'last_name', 'username', 'email') | |
50 | 50 | |
51 | 51 | class Meta: |
52 | - fields = ('first_name', 'last_name', 'username') | |
52 | + fields = ('first_name', 'last_name', 'username', 'email') | |
53 | 53 | model = User |
54 | 54 | |
55 | 55 | def __init__(self, *args, **kwargs): | ... | ... |
... | ... | @@ -0,0 +1,47 @@ |
1 | +""" | |
2 | +Test Form class. | |
3 | +Objective: Test parameters, and behavior. | |
4 | +""" | |
5 | +from colab.accounts.forms import UserForm | |
6 | +from colab.accounts.models import User | |
7 | +from django.test import TestCase, Client | |
8 | +from django import forms | |
9 | +from django.core.exceptions import ValidationError | |
10 | +from re import search | |
11 | + | |
12 | +class FormTest(TestCase): | |
13 | + | |
14 | + def setUp(self): | |
15 | + user = User() | |
16 | + user.username = "USERtestCoLaB" | |
17 | + user.set_password("123colab4") | |
18 | + user.email = "usertest@colab.com.br" | |
19 | + user.id = 1 | |
20 | + user.twitter = "usertestcolab" | |
21 | + user.facebook = "usertestcolab" | |
22 | + user.first_name = "USERtestCoLaB" | |
23 | + user.last_name = "COLAB" | |
24 | + user.save() | |
25 | + | |
26 | + def create_form_data(self): | |
27 | + form_data = {'email': 'usertest@colab.com.br', | |
28 | + 'first_name': 'colabName', | |
29 | + 'last_name': 'secondName', | |
30 | + 'username': 'colab', | |
31 | + 'password1': '123colab4', | |
32 | + 'password2': '123colab4'} | |
33 | + form = UserForm(data=form_data) | |
34 | + return form | |
35 | + | |
36 | + def test_already_registered_email(self): | |
37 | + form = self.create_form_data() | |
38 | + self.assertFalse(form.is_valid()) | |
39 | + | |
40 | + def test_registered_email_message(self): | |
41 | + tryToFind = r"<a href='login'>sign in<a/>" | |
42 | + form = self.create_form_data() | |
43 | + matched = search(tryToFind, str(form)) | |
44 | + self.assertIsNotNone(matched) | |
45 | + | |
46 | + def tearDown(self): | |
47 | + pass | ... | ... |