]> git.parisson.com Git - django-social-auth.git/commitdiff
Added testing for cached backend loading.
authorStephen McDonald <steve@jupo.org>
Sat, 24 Dec 2011 20:30:32 +0000 (07:30 +1100)
committerStephen McDonald <steve@jupo.org>
Sat, 24 Dec 2011 20:30:32 +0000 (07:30 +1100)
social_auth/tests/base.py
social_auth/tests/facebook.py
social_auth/tests/google.py
social_auth/tests/twitter.py

index 0120a2a7e7b274601fc7bdccbc77a7bfeb6e9e3b..26695eae1b9da9d1c9b8069400449c0a4072cda4 100644 (file)
@@ -29,6 +29,18 @@ class SocialAuthTestsCase(unittest.TestCase):
         self.client = Client(**client_kwargs)
         super(SocialAuthTestsCase, self).__init__(*args, **kwargs)
 
+    def test_backend_cache(self):
+        """Ensure that the backend for the testcase gets cached."""
+        try:
+            self.name
+        except AttributeError:
+            pass
+        else:
+            from social_auth import backends
+            backends.BACKENDS = {}
+            self.client.get(self.reverse('socialauth_begin', self.name))
+            self.assertTrue(self.name in backends.BACKENDS)
+
     def get_content(self, url, data=None, use_cookies=False):
         """Return content for given url, if data is not None, then a POST
         request will be issued, otherwise GET will be used"""
index c0c324b8bb3884b01d9eae9d59378faf2208c85b..1eb27359534bbea98d98d6a7ae91d29021bf5aeb 100644 (file)
@@ -8,6 +8,7 @@ from social_auth.tests.base import SocialAuthTestsCase, FormParserByID
 class FacebookTestCase(SocialAuthTestsCase):
     SERVER_NAME = 'myapp.com'
     SERVER_PORT = '8000'
+    name = 'facebook'
 
     def setUp(self, *args, **kwargs):
         super(FacebookTestCase, self).setUp(*args, **kwargs)
index 94509fa92673beb921fdfd7acb5371067cab234f..9f3cd1daede3021cdcf34768645a40177666baae 100644 (file)
@@ -7,6 +7,9 @@ from social_auth.tests.base import SocialAuthTestsCase, FormParserByID, \
 
 
 class GoogleTestCase(SocialAuthTestsCase):
+
+    name = 'google'
+
     def setUp(self, *args, **kwargs):
         super(GoogleTestCase, self).setUp(*args, **kwargs)
         self.user = getattr(settings, 'TEST_GOOGLE_USER', None)
index 9a77a6075d9a2e61f568fd3e433056cf20f8202b..9af0a837b2bcd2de1ea2c1d254669a12d026e376 100644 (file)
@@ -5,6 +5,9 @@ from social_auth.tests.base import SocialAuthTestsCase, FormParserByID, \
 
 
 class TwitterTestCase(SocialAuthTestsCase):
+
+    name = 'twitter'
+
     def setUp(self, *args, **kwargs):
         super(TwitterTestCase, self).setUp(*args, **kwargs)
         self.user = getattr(settings, 'TEST_TWITTER_USER', None)
@@ -18,6 +21,7 @@ class TwitterTestLogin(TwitterTestCase):
     def test_login_succeful(self):
         response = self.client.get(self.reverse('socialauth_begin', 'twitter'))
         # social_auth must redirect to service page
+        #import pdb; pdb.set_trace()
         self.assertEqual(response.status_code, 302)
 
         # Open first redirect page, it contains user login form because