From a14b61e8ecd0b8bd4dedb10cf9a2134f743a8b60 Mon Sep 17 00:00:00 2001 From: Miguel Araujo Perez Date: Sun, 1 May 2011 14:17:59 +0200 Subject: [PATCH] Adding Selenium2 google-oauth and google-oauth2 tests. Both up and running. --- contrib/tests/test_core.py | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/contrib/tests/test_core.py b/contrib/tests/test_core.py index 36e1b62..c980f1b 100644 --- a/contrib/tests/test_core.py +++ b/contrib/tests/test_core.py @@ -41,3 +41,61 @@ class BackendsTest(TestCase): raise Exception("The user didn't logged in") # Here we could test the User's fields + + def test_google_oauth_backend(self): + TEST_GOOGLE_USER = getattr(settings, 'TEST_GOOGLE_USER', None) + TEST_GOOGLE_PASSWORD = getattr(settings, 'TEST_GOOGLE_PASSWORD', None) + self.assertTrue(TEST_GOOGLE_USER) + self.assertTrue(TEST_GOOGLE_PASSWORD) + + self.driver.get("http://social.matiasaguirre.net/login/google-oauth/") + + # We log in + username_field = self.driver.find_element_by_id("Email") + username_field.send_keys(TEST_GOOGLE_USER) + + password_field = self.driver.find_element_by_id("Passwd") + password_field.send_keys(TEST_GOOGLE_PASSWORD) + password_field.submit() + + # The application might be already allowed + try: + self.driver.find_element_by_id("allow").click() + except: + pass + + # We check the user logged in + heading = self.driver.find_element_by_id("heading") + if not heading.text == u'Logged in!': + raise Exception("The user didn't logged in") + + # Here we could test the User's fields + + def test_google_oauth2_backend(self): + TEST_GOOGLE_USER = getattr(settings, 'TEST_GOOGLE_USER', None) + TEST_GOOGLE_PASSWORD = getattr(settings, 'TEST_GOOGLE_PASSWORD', None) + self.assertTrue(TEST_GOOGLE_USER) + self.assertTrue(TEST_GOOGLE_PASSWORD) + + self.driver.get("http://social.matiasaguirre.net/login/google-oauth2/") + + # We log in + username_field = self.driver.find_element_by_id("Email") + username_field.send_keys(TEST_GOOGLE_USER) + + password_field = self.driver.find_element_by_id("Passwd") + password_field.send_keys(TEST_GOOGLE_PASSWORD) + password_field.submit() + + # The application might be already allowed + try: + self.driver.find_element_by_id("submit_approve_access").click() + except: + pass + + # We check the user logged in + heading = self.driver.find_element_by_id("heading") + if not heading.text == u'Logged in!': + raise Exception("The user didn't logged in") + + # Here we could test the User's fields -- 2.39.5