From ad365b0e3e80e09c875a1d952de35cb39f4eafad Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 25 Dec 2011 07:30:32 +1100 Subject: [PATCH] Added testing for cached backend loading. --- social_auth/tests/base.py | 12 ++++++++++++ social_auth/tests/facebook.py | 1 + social_auth/tests/google.py | 3 +++ social_auth/tests/twitter.py | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/social_auth/tests/base.py b/social_auth/tests/base.py index 0120a2a..26695ea 100644 --- a/social_auth/tests/base.py +++ b/social_auth/tests/base.py @@ -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""" diff --git a/social_auth/tests/facebook.py b/social_auth/tests/facebook.py index c0c324b..1eb2735 100644 --- a/social_auth/tests/facebook.py +++ b/social_auth/tests/facebook.py @@ -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) diff --git a/social_auth/tests/google.py b/social_auth/tests/google.py index 94509fa..9f3cd1d 100644 --- a/social_auth/tests/google.py +++ b/social_auth/tests/google.py @@ -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) diff --git a/social_auth/tests/twitter.py b/social_auth/tests/twitter.py index 9a77a60..9af0a83 100644 --- a/social_auth/tests/twitter.py +++ b/social_auth/tests/twitter.py @@ -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 -- 2.39.5