#NEWLINE# @ responses . activate #NEWLINE# def test_context_local( ) : #NEWLINE# #INDENT# responses . add ( responses . GET , 'https://google.com' ) #NEWLINE# app1 = Flask ( __name__ ) #NEWLINE# jbp1 = make_jira_blueprint ( 'https://t1.atlassian.com' , 'foo1' , 'bar1' , redirect_to = 'url1' ) #NEWLINE# app1 . register_blueprint ( jbp1 ) #NEWLINE# app2 = Flask ( __name__ ) #NEWLINE# jbp2 = make_jira_blueprint ( 'https://t2.atlassian.com' , 'foo2' , 'bar2' , redirect_to = 'url2' ) #NEWLINE# app2 . register_blueprint ( jbp2 ) #NEWLINE# with pytest . raises ( RuntimeError ) : #NEWLINE# #INDENT# jira . get ( 'https://google.com' ) #NEWLINE# #UNINDENT# with app1 . test_request_context ( '/' ) : #NEWLINE# #INDENT# jbp1 . session . auth . client . get_oauth_signature = mock . Mock ( return_value = 'sig1' ) #NEWLINE# jbp2 . session . auth . client . get_oauth_signature = mock . Mock ( return_value = 'sig2' ) #NEWLINE# app1 . preprocess_request ( ) #NEWLINE# jira . get ( 'https://google.com' ) #NEWLINE# auth_header = dict ( parse_authorization_header ( responses . calls [ 0 ] . request . headers [ 'Authorization' ] . decode ( 'utf-8' ) ) ) #NEWLINE# assert ( auth_header [ 'oauth_consumer_key' ] == 'foo1' ) #NEWLINE# assert ( auth_header [ 'oauth_signature' ] == 'sig1' ) #NEWLINE# #UNINDENT# with app2 . test_request_context ( '/' ) : #NEWLINE# #INDENT# jbp1 . session . auth . client . get_oauth_signature = mock . Mock ( return_value = 'sig1' ) #NEWLINE# jbp2 . session . auth . client . get_oauth_signature = mock . Mock ( return_value = 'sig2' ) #NEWLINE# app2 . preprocess_request ( ) #NEWLINE# jira . get ( 'https://google.com' ) #NEWLINE# auth_header = dict ( parse_authorization_header ( responses . calls [ 1 ] . request . headers [ 'Authorization' ] . decode ( 'utf-8' ) ) ) #NEWLINE# assert ( auth_header [ 'oauth_consumer_key' ] == 'foo2' ) #NEWLINE# assert ( auth_header [ 'oauth_signature' ] == 'sig2' )