Commit 09c63134886938cdd9a1307711abe73ade21638b

Authored by Matheus Fernandes
Committed by Sergio Oliveira
1 parent ce336297

Applied flake8 into accounts models and tests files

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>
colab/accounts/models.py
@@ -2,15 +2,12 @@ @@ -2,15 +2,12 @@
2 2
3 import urlparse 3 import urlparse
4 4
5 -from django.db import models, DatabaseError  
6 -from django.contrib.auth.hashers import check_password 5 +from django.db import models
7 from django.contrib.auth.models import AbstractUser 6 from django.contrib.auth.models import AbstractUser
8 from django.core import validators 7 from django.core import validators
9 from django.core.urlresolvers import reverse 8 from django.core.urlresolvers import reverse
10 from django.utils.translation import ugettext_lazy as _ 9 from django.utils.translation import ugettext_lazy as _
11 10
12 -from conversejs import xmpp  
13 -  
14 from .utils import mailman 11 from .utils import mailman
15 12
16 13
@@ -25,7 +22,7 @@ class User(AbstractUser): @@ -25,7 +22,7 @@ class User(AbstractUser):
25 facebook = models.CharField(max_length=128, null=True, blank=True) 22 facebook = models.CharField(max_length=128, null=True, blank=True)
26 google_talk = models.EmailField(null=True, blank=True) 23 google_talk = models.EmailField(null=True, blank=True)
27 github = models.CharField(max_length=128, null=True, blank=True, 24 github = models.CharField(max_length=128, null=True, blank=True,
28 - verbose_name=u'github') 25 + verbose_name=u'github')
29 webpage = models.CharField(max_length=256, null=True, blank=True) 26 webpage = models.CharField(max_length=256, null=True, blank=True)
30 verification_hash = models.CharField(max_length=32, null=True, blank=True) 27 verification_hash = models.CharField(max_length=32, null=True, blank=True)
31 modified = models.DateTimeField(auto_now=True) 28 modified = models.DateTimeField(auto_now=True)
colab/accounts/tests/test_request.py
@@ -5,12 +5,8 @@ Objective: Test requests. @@ -5,12 +5,8 @@ Objective: Test requests.
5 5
6 from django.test import TestCase, Client 6 from django.test import TestCase, Client
7 from django.test.client import RequestFactory 7 from django.test.client import RequestFactory
8 -from django.contrib.messages.storage.fallback import FallbackStorage  
9 -from colab.accounts.views import ManageUserSubscriptionsView  
10 -from colab.accounts.views import UserProfileDetailView  
11 from colab.accounts.models import User 8 from colab.accounts.models import User
12 -from django.http.response import Http404  
13 -from colab.accounts.views import signup 9 +
14 10
15 class RequestTest(TestCase): 11 class RequestTest(TestCase):
16 12
@@ -22,7 +18,7 @@ class RequestTest(TestCase): @@ -22,7 +18,7 @@ class RequestTest(TestCase):
22 # TODO 18 # TODO
23 pass 19 pass
24 20
25 - def test_invalid_user_profile_url(self): 21 + def test_invalid_user_profile_url(self):
26 response = self.client.get('/account/johndoe/') 22 response = self.client.get('/account/johndoe/')
27 self.assertEqual(404, response.status_code) 23 self.assertEqual(404, response.status_code)
28 24
colab/accounts/tests/test_user.py
@@ -3,59 +3,54 @@ Test User class. @@ -3,59 +3,54 @@ Test User class.
3 Objective: Test parameters, and behavior. 3 Objective: Test parameters, and behavior.
4 """ 4 """
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
7 7
8 8
9 class UserTest(TestCase): 9 class UserTest(TestCase):
10 -  
11 - def setUp(self):  
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  
26 -  
27 - def test_check_password(self):  
28 - self.assertTrue(self.user.check_password("123colab4"))  
29 - self.assertFalse(self.user.check_password("1234"))  
30 -  
31 - def test_get_absolute_url(self):  
32 - url = self.user.get_absolute_url()  
33 - self.assertEqual("/account/usertestcolab", url)  
34 -  
35 -  
36 - def test_twitter_link(self):  
37 - link_twitter = self.user.twitter_link()  
38 - self.assertEqual('https://twitter.com/usertestcolab', link_twitter)  
39 -  
40 - def test_facebook_link(self):  
41 - link_facebook = self.user.facebook_link()  
42 - self.assertEqual('https://www.facebook.com/usertestcolab', link_facebook)  
43 -  
44 -  
45 - def test_mailinglists(self):  
46 - empty_list = ()  
47 - self.assertEqual(empty_list, self.user.mailinglists())  
48 -  
49 -  
50 - def test_update_subscription(self):  
51 - pass  
52 - # TODO: You should have mailman connection.  
53 -  
54 - def test_save(self):  
55 - username_test = "USERtestCoLaB"  
56 -  
57 - user_db = User.objects.get(id=1)  
58 - self.assertEqual(user_db.username, username_test.lower())  
59 - self.user.delete()  
60 -  
61 10
  11 + def setUp(self):
  12 + self.user = self.create_user()
  13 +
  14 + def create_user(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.save()
  23 +
  24 + return user
  25 +
  26 + def test_check_password(self):
  27 + self.assertTrue(self.user.check_password("123colab4"))
  28 + self.assertFalse(self.user.check_password("1234"))
  29 +
  30 + def test_get_absolute_url(self):
  31 + url = self.user.get_absolute_url()
  32 + self.assertEqual("/account/usertestcolab", url)
  33 +
  34 + def test_twitter_link(self):
  35 + link_twitter = self.user.twitter_link()
  36 + self.assertEqual('https://twitter.com/usertestcolab', link_twitter)
  37 +
  38 + def test_facebook_link(self):
  39 + link_facebook = self.user.facebook_link()
  40 + self.assertEqual('https://www.facebook.com/usertestcolab',
  41 + link_facebook)
  42 +
  43 + def test_mailinglists(self):
  44 + empty_list = ()
  45 + self.assertEqual(empty_list, self.user.mailinglists())
  46 +
  47 + def test_update_subscription(self):
  48 + pass
  49 + # TODO: You should have mailman connection.
  50 +
  51 + def test_save(self):
  52 + username_test = "USERtestCoLaB"
  53 +
  54 + user_db = User.objects.get(id=1)
  55 + self.assertEqual(user_db.username, username_test.lower())
  56 + self.user.delete()