@@ -52,71 +52,5 @@ def test_add_interceptor(self):
5252 signing_layer2 = get_signing_layer (self , requests )
5353 self .assertNotEqual (signing_layer1 , signing_layer2 )
5454
55- """ these will fail because the test keys can't access the service, you'll need to insert a valid key file, password, and consumer key """
56- def localonly_test_without_interceptor (self ):
57- key_file = './test_key_container.p12'
58- key_password = "Password1"
59- consumer_key = 'uLXKmWNmIkzIGKfA2injnNQqpZaxaBSKxa3ixEVu2f283c95!33b9b2bd960147e387fa6f3f238f07170000000000000000'
60- signing_key = authenticationutils .load_signing_key (key_file , key_password )
61-
62- baseUrl = 'https://sandbox.api.mastercard.com'
63-
64- queryMap = {
65- "Format" : "JSON" , # change this to toggle between and XML or JSON response
66- "fxDate" : "2016-09-30" ,
67- "transCurr" : "ALL" ,
68- "crdhldBillCurr" : "DZD" ,
69- "bankFee" : "5" ,
70- "transAmt" : "23"
71- }
72-
73- uri = baseUrl + "/settlement/currencyrate/conversion-rate?" + urlencode (queryMap )
74- header = OAuth ().get_authorization_header (uri , 'GET' , None , consumer_key , signing_key )
75- headers = {'Authorization' : header , 'Content-Type' : 'application/json' }
76-
77- r = requests .get (uri , headers = headers )
78- print (r .text )
79-
80- """ these will fail because the test keys can't access the service, you'll need to insert a valid key file, password, and consumer key """
81- def localonly_test_with_interceptor (self ):
82- key_file = './test_key_container.p12'
83- key_password = "Password1"
84- consumer_key = 'uLXKmWNmIkzIGKfA2injnNQqpZaxaBSKxa3ixEVu2f283c95!33b9b2bd960147e387fa6f3f238f07170000000000000000'
85- signing_key = authenticationutils .load_signing_key (key_file , key_password )
86-
87- baseUrl = 'https://sandbox.api.mastercard.com'
88-
89- test_cli = APIClientForTest ()
90- add_signing_layer (self , test_cli , key_file , key_password , consumer_key )
91-
92- queryMap = {
93- "Format" : "JSON" , # change this to toggle between and XML or JSON response
94- "fxDate" : "2016-09-30" ,
95- "transCurr" : "ALL" ,
96- "crdhldBillCurr" : "DZD" ,
97- "bankFee" : "5" ,
98- "transAmt" : "23"
99- }
100-
101- uri = baseUrl + "/settlement/currencyrate/conversion-rate"
102-
103- r = test_cli .request ('GET' , uri , query_params = queryMap )
104- print (r .text )
105-
10655if __name__ == '__main__' :
107- unittest .main ()
108-
109- class APIClientForTest ():
110-
111- def request (self , method , uri , query_params = None , headers = None , post_params = None , body = None , _preload_content = True , _request_timeout = None ):
112- res = None
113-
114- if query_params :
115- uri += '?' + urlencode (query_params )
116-
117- if method == 'GET' :
118- res = requests .get (uri , headers = headers )
119- if method == 'POST' :
120- res = requests .post (uri , headers = headers , body = body )
121-
122- return res
56+ unittest .main ()
0 commit comments