Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@peplin
Created February 20, 2011 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peplin/836086 to your computer and use it in GitHub Desktop.
Save peplin/836086 to your computer and use it in GitHub Desktop.
import mockito
import faker
import oauth_access.access
def mock_facebook_success(user_data=None):
user_data = user_data or {'id': '42',
'email': faker.internet.email(),
'first_name': faker.name.first_name(),
'last_name': faker.name.last_name()}
mockito.when(oauth_access.access.OAuthAccess).check_token(
mockito.any(), mockito.any()).thenReturn(
oauth_access.access.OAuth20Token("FAKE_TOKEN"))
mockito.when(oauth_access.access.OAuthAccess).make_api_call(
mockito.any(), "https://graph.facebook.com/me", mockito.any()
).thenReturn(user_data)
def mock_facebook_failure():
mockito.when(oauth_access.access.OAuthAccess).check_token(
mockito.any(), mockito.any()).thenReturn(None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment