Skip to content

Instantly share code, notes, and snippets.

@aditya1702
Created May 19, 2016 16:53
Show Gist options
  • Save aditya1702/e063182c96448afd7ddf87e8202ac81c to your computer and use it in GitHub Desktop.
Save aditya1702/e063182c96448afd7ddf87e8202ac81c to your computer and use it in GitHub Desktop.
from tests.utils import OpenEventTestCase
from tests.setup_database import Setup
from open_event import current_app as app
from oauthlib.oauth2 import WebApplicationClient
from tests.object_mother import ObjectMother
from open_event.helpers.data import save_to_db
class TestGoogleOauth(OpenEventTestCase):
def setUp(self):
self.app = Setup.create_app()
//this is the test that is failing.Other tests are successfull. I am testing that once the user is already saved to the database
it should not go ahead but directly load the admin page.
def test_redirect(self):
with app.test_request_context():
user = ObjectMother.get_user()
save_to_db(user, "User Saved")
self.assertTrue("Create" in self.app.get("/gCallback/?state=dummy_state&code=d/sfaummy_code").data)
def test_code_in_uri(self):
client = WebApplicationClient('some_client_id')
uri = "https://gCallback/?state=dummy_state&code=dummy_code"
self.assertTrue('dummy_code' in client.parse_request_uri_response(uri, state='dummy_state').values())
def test_error_return(self):
"""This tests the various errors returned by callback function"""
with app.test_request_context():
self.assertTrue(self.app.get("/gCallback/?state=dummy_state&code=dummy_code&error=access denied/").data,
"You denied access")
self.assertTrue(self.app.get("/gCallback/?state=dummy_state&code=dummy_code&error=12234/").data,
"Error encountered")
self.assertTrue(self.app.get("/gCallback/?no_code_and_state/").data, "Submit")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment