#NEWLINE# @ patch ( 'requests.Response' ) #NEWLINE# @ patch ( 'dcos.http._request' ) #NEWLINE# @ patch ( 'dcos.http._get_http_auth' ) #NEWLINE# def test_request_with_auth_oauth( mock , req_mock , auth_mock ) : #NEWLINE# #INDENT# mock . url = 'http://domain.com' #NEWLINE# mock . headers = { #NEWLINE# #INDENT# 'www-authenticate' : 'oauthjwt' , #NEWLINE# #UNINDENT# } #NEWLINE# mock . status_code = 401 #NEWLINE# auth = http . DCOSAcsAuth ( 'token' ) #NEWLINE# auth_mock . return_value = auth #NEWLINE# mock2 = copy . deepcopy ( mock ) #NEWLINE# mock2 . status_code = 200 #NEWLINE# req_mock . return_value = mock2 #NEWLINE# response = http . _request_with_auth ( mock , 'method' , mock . url ) #NEWLINE# assert ( response . status_code == 200 )