Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improved tests files in order to a better adaptation to UnitTests fea…

…tures
  • Loading branch information...
commit 7e65be6e5cf3597d1d64725735891c9c491bde9a 1 parent 09ebecd
@pablorecio pablorecio authored
View
34 django_facebook/tests/test.py → django_facebook/tests.py
@@ -5,13 +5,12 @@
from django_facebook.auth_backends import FacebookBackend
from django_facebook.connect import (_register_user, connect_user,
CONNECT_ACTIONS)
-from django_facebook.tests.base import FacebookTest
+from django_facebook.tests_utils.base import FacebookTest
from django_facebook.utils import get_profile_class
from django_facebook.api import (get_facebook_graph, FacebookUserConverter,
get_persistent_graph)
from django_facebook import signals
import logging
-import unittest
from open_facebook.api import FacebookConnection
from functools import partial
from django_facebook.utils import cleanup_oauth_url
@@ -48,12 +47,12 @@ def test_full_connect(self):
graph = get_facebook_graph(access_token='short_username')
FacebookUserConverter(graph)
action, user = connect_user(self.request, facebook_graph=graph)
- assert action == CONNECT_ACTIONS.REGISTER
+ self.assertEqual(action, CONNECT_ACTIONS.REGISTER)
action, user = connect_user(self.request, facebook_graph=graph)
- assert action == CONNECT_ACTIONS.CONNECT
+ self.assertEqual(action, CONNECT_ACTIONS.CONNECT)
self.request.user = AnonymousUser()
action, user = connect_user(self.request, facebook_graph=graph)
- assert action == CONNECT_ACTIONS.LOGIN
+ self.assertEqual(action, CONNECT_ACTIONS.LOGIN)
def test_utf8(self):
graph = get_facebook_graph(access_token='unicode_string')
@@ -72,7 +71,7 @@ def test_no_email_registration(self):
def test_current_user(self):
facebook = get_facebook_graph(access_token='tschellenbach')
action, user = connect_user(self.request, facebook_graph=facebook)
- assert action == CONNECT_ACTIONS.LOGIN
+ self.assertEqual(action, CONNECT_ACTIONS.LOGIN)
def test_new_user(self):
facebook = get_facebook_graph(access_token='new_user')
@@ -81,14 +80,14 @@ def test_new_user(self):
def test_short_username(self):
facebook = get_facebook_graph(access_token='short_username')
action, user = connect_user(self.request, facebook_graph=facebook)
- assert len(user.username) > 4
- assert action == CONNECT_ACTIONS.REGISTER
+ self.assertTrue(len(user.username) > 4)
+ self.assertEqual(action, CONNECT_ACTIONS.REGISTER)
def test_gender(self):
graph = get_facebook_graph(access_token='new_user')
facebook = FacebookUserConverter(graph)
data = facebook.facebook_registration_data()
- assert data['gender'] == 'm'
+ self.assertEqual(data['gender'], 'm')
def test_double_username(self):
'''
@@ -102,13 +101,14 @@ def test_double_username(self):
self.request.user = AnonymousUser()
facebook = get_facebook_graph(access_token='same_username')
action, new_user = connect_user(self.request, facebook_graph=facebook)
- assert user.username != new_user.username and user.id != new_user.id
+ self.assertNotEqual(user.username, new_user.username)
+ self.assertNotEqual(user.id, new_user.id)
def test_registration_form(self):
'''
Django_facebook should use user supplied registration form if given
'''
- facebook_settings.FACEBOOK_REGISTRATION_FORM = 'django_facebook.tests.forms.SignupForm'
+ facebook_settings.FACEBOOK_REGISTRATION_FORM = 'django_facebook.tests_utils.forms.SignupForm'
facebook = get_facebook_graph(access_token='short_username')
action, user = connect_user(self.request, facebook_graph=facebook)
# The test form always sets username to test form
@@ -123,17 +123,17 @@ def test_auth_backend(self):
facebook_email = user.email
facebook_id = user.get_profile().facebook_id
auth_user = backend.authenticate(facebook_email=facebook_email)
- assert auth_user == user
+ self.assertEqual(auth_user, user)
auth_user = backend.authenticate(facebook_id=facebook_id)
- assert auth_user == user
+ self.assertEqual(auth_user, user)
auth_user = backend.authenticate(facebook_id=facebook_id,
facebook_email=facebook_email)
- assert auth_user == user
+ self.assertEqual(auth_user, user)
auth_user = backend.authenticate()
- assert not auth_user
+ self.assertIsNone(auth_user)
class ErrorMappingTest(FacebookTest):
@@ -195,7 +195,3 @@ def post_update(sender, profile, facebook_data, **kwargs):
'pre_update_signal'), True)
self.assertEqual(hasattr(user.get_profile(),
'post_update_signal'), True)
-
-
-if __name__ == '__main__':
- unittest.main()
View
0  django_facebook/tests/__init__.py → django_facebook/tests_utils/__init__.py
File renamed without changes
View
2  django_facebook/tests/base.py → django_facebook/tests_utils/base.py
@@ -23,7 +23,7 @@ def request(self, **request):
class FacebookTest(TestCase):
def setUp(self):
- from django_facebook.tests.mock_official_sdk import MockFacebookAPI
+ from django_facebook.tests_utils.mock_official_sdk import MockFacebookAPI
from open_facebook import api
import open_facebook
api.OpenFacebook = MockFacebookAPI
View
0  django_facebook/tests/convert_json.py → django_facebook/tests_utils/convert_json.py
File renamed without changes
View
0  django_facebook/tests/forms.py → django_facebook/tests_utils/forms.py
File renamed without changes
View
4 django_facebook/tests/mock_official_sdk.py → ...facebook/tests_utils/mock_official_sdk.py
@@ -5,10 +5,10 @@ class MockFacebookAPI(OpenFacebook):
mock = True
def me(self):
- from django_facebook.tests.sample_data.user_data import user_data
+ from django_facebook.tests_utils.sample_data.user_data import user_data
data = user_data[self.access_token]
return data
def is_authenticated(self, *args, **kwargs):
- from django_facebook.tests.sample_data.user_data import user_data
+ from django_facebook.tests_utils.sample_data.user_data import user_data
return self.access_token in user_data
View
0  ...go_facebook/tests/sample_data/__init__.py → ...ebook/tests_utils/sample_data/__init__.py
File renamed without changes
View
0  ...o_facebook/tests/sample_data/user_data.py → ...book/tests_utils/sample_data/user_data.py
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.