Commit ce336297846cb4625068a559e02072027e8a66ad
Committed by
Sergio Oliveira
1 parent
fee0c86c
Exists in
master
and in
39 other branches
Finished to implement user test
Signed-off-by: Carolina Ramalho <carol15022@hotmail.com> Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> Signed-off-by: Matheus Fernandes <matheus.souza.fernandes@gmail.com>
Showing
2 changed files
with
34 additions
and
13 deletions
Show diff stats
colab/accounts/models.py
@@ -15,6 +15,10 @@ from .utils import mailman | @@ -15,6 +15,10 @@ from .utils import mailman | ||
15 | 15 | ||
16 | 16 | ||
17 | class User(AbstractUser): | 17 | class User(AbstractUser): |
18 | + """ | ||
19 | + For more information about AbstractUser | ||
20 | + @see: https://docs.djangoproject.com/en/1.7/ref/contrib/auth/ | ||
21 | + """ | ||
18 | institution = models.CharField(max_length=128, null=True, blank=True) | 22 | institution = models.CharField(max_length=128, null=True, blank=True) |
19 | role = models.CharField(max_length=128, null=True, blank=True) | 23 | role = models.CharField(max_length=128, null=True, blank=True) |
20 | twitter = models.CharField(max_length=128, null=True, blank=True) | 24 | twitter = models.CharField(max_length=128, null=True, blank=True) |
colab/accounts/tests/test_user.py
@@ -5,37 +5,54 @@ Objective: Test parameters, and behavior. | @@ -5,37 +5,54 @@ Objective: Test parameters, and behavior. | ||
5 | from colab.accounts.models import User | 5 | from colab.accounts.models import User |
6 | from django.test import TestCase, Client | 6 | from django.test import TestCase, Client |
7 | 7 | ||
8 | + | ||
8 | class UserTest(TestCase): | 9 | class UserTest(TestCase): |
9 | 10 | ||
10 | def setUp(self): | 11 | def setUp(self): |
11 | - self.user = User() | ||
12 | - pass | 12 | + self.user = self.create_user() |
13 | + | ||
14 | + | ||
15 | + def create_user(self): | ||
16 | + user = User() | ||
17 | + user.username = "USERtestCoLaB" | ||
18 | + user.set_password("123colab4") | ||
19 | + user.email = "usertest@colab.com.br" | ||
20 | + user.id = 1 | ||
21 | + user.twitter = "usertestcolab" | ||
22 | + user.facebook = "usertestcolab" | ||
23 | + user.save() | ||
24 | + | ||
25 | + return user | ||
13 | 26 | ||
14 | def test_check_password(self): | 27 | def test_check_password(self): |
15 | - pass | 28 | + self.assertTrue(self.user.check_password("123colab4")) |
29 | + self.assertFalse(self.user.check_password("1234")) | ||
16 | 30 | ||
17 | def test_get_absolute_url(self): | 31 | def test_get_absolute_url(self): |
18 | - pass | 32 | + url = self.user.get_absolute_url() |
33 | + self.assertEqual("/account/usertestcolab", url) | ||
34 | + | ||
19 | 35 | ||
20 | def test_twitter_link(self): | 36 | def test_twitter_link(self): |
21 | - pass | 37 | + link_twitter = self.user.twitter_link() |
38 | + self.assertEqual('https://twitter.com/usertestcolab', link_twitter) | ||
22 | 39 | ||
23 | def test_facebook_link(self): | 40 | def test_facebook_link(self): |
24 | - pass | 41 | + link_facebook = self.user.facebook_link() |
42 | + self.assertEqual('https://www.facebook.com/usertestcolab', link_facebook) | ||
43 | + | ||
25 | 44 | ||
26 | - def test_mailinglist(self): | ||
27 | - pass | 45 | + def test_mailinglists(self): |
46 | + empty_list = () | ||
47 | + self.assertEqual(empty_list, self.user.mailinglists()) | ||
48 | + | ||
28 | 49 | ||
29 | def test_update_subscription(self): | 50 | def test_update_subscription(self): |
30 | pass | 51 | pass |
52 | + # TODO: You should have mailman connection. | ||
31 | 53 | ||
32 | def test_save(self): | 54 | def test_save(self): |
33 | username_test = "USERtestCoLaB" | 55 | username_test = "USERtestCoLaB" |
34 | - self.user.username = username_test | ||
35 | - self.user.set_password("123colab4") | ||
36 | - self.user.email = "usertest@colab.com.br" | ||
37 | - self.user.id = 1 | ||
38 | - self.user.save() | ||
39 | 56 | ||
40 | user_db = User.objects.get(id=1) | 57 | user_db = User.objects.get(id=1) |
41 | self.assertEqual(user_db.username, username_test.lower()) | 58 | self.assertEqual(user_db.username, username_test.lower()) |