1- from datetime import datetime , timedelta
21import unittest
2+ from datetime import datetime , timedelta
3+ from decimal import Decimal as D
34from unittest .mock import patch
4- from urllib .parse import urljoin
55
6- from santander_sdk .api_client .client import TOKEN_ENDPOINT , SantanderApiClient
7- from santander_sdk .api_client .client_configuration import (
8- SantanderClientConfiguration ,
9- )
10- from santander_sdk .api_client .exceptions import SantanderClientException
11- from decimal import Decimal as D
126from mock .santander_mocker import (
137 SANTANDER_URL ,
14- get_dict_token_response ,
15- get_dict_token_request ,
168 get_dict_payment_pix_request ,
179 get_dict_payment_pix_response ,
10+ get_dict_token_request ,
11+ get_dict_token_response ,
1812)
13+
14+ from santander_sdk .api_client .client import TOKEN_ENDPOINT , SantanderApiClient
15+ from santander_sdk .api_client .client_configuration import (
16+ SantanderClientConfiguration ,
17+ )
18+ from santander_sdk .api_client .exceptions import SantanderClientException
1919from santander_sdk .types import OrderStatus
2020
2121
@@ -93,7 +93,7 @@ def test_request_token(self, mock_post):
9393
9494 token_data = self .client ._request_token ()
9595 mock_post .assert_called_once_with (
96- urljoin ( SANTANDER_URL , TOKEN_ENDPOINT ) ,
96+ TOKEN_ENDPOINT ,
9797 data = self .token_request_mock ,
9898 verify = True ,
9999 timeout = 60 ,
@@ -119,42 +119,35 @@ def test_request(self, mock_ensure_requirements, mock_request):
119119 mock_request .return_value .json .return_value = response_dict
120120
121121 # GET (Não precisa de data)
122- response_data = self .client ._request ("GET" , "test_endpoint" )
122+ response_data = self .client ._request ("GET" , "/ test_endpoint" )
123123 assert response_data == response_dict , (
124124 "Deveria ter retornado o dict de resposta"
125125 )
126126 mock_request .assert_called_once_with (
127- "GET" , f" { SANTANDER_URL } /test_endpoint" , json = None , params = None , timeout = 60
127+ "GET" , " /test_endpoint" , json = None , params = None , timeout = 60
128128 )
129129
130130 # Post (Precisa de data)
131131 mock_request .reset_mock ()
132- response_data = self .client ._request ("POST" , "test_endpoint" , data = request_dict )
132+ response_data = self .client ._request (
133+ "POST" , "/test_endpoint" , data = request_dict
134+ )
133135 assert response_data == response_dict , (
134136 "Deveria ter retornado o dict de resposta"
135137 )
136138 mock_request .assert_called_once_with (
137139 "POST" ,
138- f" { SANTANDER_URL } /test_endpoint" ,
140+ " /test_endpoint" ,
139141 json = request_dict ,
140142 params = None ,
141143 timeout = 60 ,
142144 )
143145
144146 def test_prepare_url (self ):
145147 self .client .config .workspace_id = "d6c7b8a9e"
146- assert (
147- self .client ._prepare_url ("test_endpoint/qr" )
148- == f"{ SANTANDER_URL } /test_endpoint/qr"
149- )
150- assert (
151- self .client ._prepare_url ("test/:WORKSPACEID" )
152- == f"{ SANTANDER_URL } /test/d6c7b8a9e"
153- )
154- assert (
155- self .client ._prepare_url (":workspaceid/pix" )
156- == f"{ SANTANDER_URL } /d6c7b8a9e/pix"
157- )
148+ assert self .client ._prepare_url ("test_endpoint/qr" ) == "test_endpoint/qr"
149+ assert self .client ._prepare_url ("test/:WORKSPACEID" ) == "test/d6c7b8a9e"
150+ assert self .client ._prepare_url (":workspaceid/pix" ) == "d6c7b8a9e/pix"
158151 self .client .config .workspace_id = ""
159152 with self .assertRaises (SantanderClientException ):
160153 self .client ._prepare_url ("test_endpoint/:workspaceid" )
0 commit comments