<s> import logging <EOL> import unittest <EOL> import requests <EOL> from mock import patch , Mock <EOL> from flask import Flask , request , redirect <EOL> from flask_github import GitHub <EOL> logger = logging . getLogger ( __name__ ) <EOL> class GitHubTestCase ( unittest . TestCase ) : <EOL> @ patch . object ( requests . Session , '<STR_LIT>' ) <EOL> @ patch . object ( GitHub , '<STR_LIT>' ) <EOL> def test_authorization ( self , auth_url , post ) : <EOL> def assert_params ( * args , ** kwargs ) : <EOL> data = kwargs . pop ( '<STR_LIT:data>' ) <EOL> assert data [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert data [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert data [ '<STR_LIT:code>' ] == '<STR_LIT>' <EOL> response = Mock ( ) <EOL> response . content = b'<STR_LIT>' <EOL> return response <EOL> post . side_effect = assert_params <EOL> auth_url . __get__ = Mock ( return_value = '<STR_LIT>' ) <EOL> app = Flask ( __name__ ) <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> github = GitHub ( app ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def login ( ) : <EOL> return github . authorize ( redirect_uri = "<STR_LIT>" ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ github . authorized_handler <EOL> def authorized ( token ) : <EOL> access_token . append ( token ) <EOL> return '<STR_LIT>' <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def handle_auth ( ) : <EOL> logger . info ( "<STR_LIT>" ) <EOL> called_auth . append ( <NUM_LIT:1> ) <EOL> assert request . args [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> logger . debug ( "<STR_LIT>" ) <EOL> assert request . args [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> logger . debug ( "<STR_LIT>" ) <EOL> return redirect ( request . args [ '<STR_LIT>' ] + '<STR_LIT>' ) <EOL> access_token = [ ] <EOL> called_auth = [ ] <EOL> client = app . test_client ( ) <EOL> client . get ( '<STR_LIT>' , follow_redirects = True ) <EOL> assert called_auth <EOL> assert access_token == [ '<STR_LIT>' ] , access_token <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> unittest . main ( ) </s>
