File tree Expand file tree Collapse file tree 4 files changed +12
-15
lines changed
Expand file tree Collapse file tree 4 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -105,17 +105,17 @@ def request(
105105 with httpx .Client () as client :
106106 # Set headers
107107 headers = self .headers .copy ()
108-
108+
109109 # Update JWT token if needed
110110 if self .jwt_token :
111111 if self .jwt_token .is_expired :
112112 self .jwt_token = Jwt .create (self )
113113 headers ['X-Cuenca-Token' ] = self .jwt_token .token
114-
114+
115115 # Merge headers from kwargs if present
116116 if 'headers' in kwargs :
117117 headers .update (kwargs .pop ('headers' ))
118-
118+
119119 # Make request
120120 resp = client .request (
121121 method = method ,
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ def _upload(
137137 files = {
138138 'file' : encoded_file ,
139139 'user_id' : str (user_id ),
140- ** {k : str (v ) if v is not None else '' for k , v in data .items ()}
140+ ** {k : str (v ) if v is not None else '' for k , v in data .items ()},
141141 }
142142 resp = session .request (
143143 'post' ,
Original file line number Diff line number Diff line change 11import datetime as dt
22
33import pytest
4- from pytest_httpx import HTTPXMock
54from cuenca_validations .errors import (
65 NoPasswordFoundError ,
76 UserNotLoggedInError ,
87)
98from freezegun import freeze_time
9+ from pytest_httpx import HTTPXMock
1010
1111from cuenca .exc import CuencaResponseException
1212from cuenca .http .client import Session
@@ -66,22 +66,20 @@ def test_request_expired_token():
6666
6767def test_overrides_session (httpx_mock : HTTPXMock ):
6868 # Setup mock response
69- httpx_mock .add_response (
70- status_code = 200 ,
71- json = {"items" : []}
72- )
73-
69+ httpx_mock .add_response (status_code = 200 , json = {"items" : []})
70+
7471 # Configure session with custom credentials
7572 session = Session ()
7673 session .configure (
7774 api_key = 'USER_API_KEY' , api_secret = 'USER_SECRET' , sandbox = True
7875 )
79-
76+
8077 # Make the request
8178 Card .first (user_id = 'USER_ID' , session = session )
82-
79+
8380 # Verify the request was made with the correct auth
8481 request = httpx_mock .get_request ()
82+ assert request is not None , "No request was captured"
8583 assert request .headers .get ("authorization" , "" ).startswith ("Basic " )
8684 assert request .url .params .get ("user_id" ) == "USER_ID"
8785
Original file line number Diff line number Diff line change 1- import pytest
21from pytest_httpx import HTTPXMock
32
43import cuenca
54
65
76def test_get_balance (httpx_mock : HTTPXMock ):
87 # It is the case when the user has transactions in the account
9- response_json = {
8+ response_json : dict = {
109 'items' : [
1110 {
1211 'id' : 'LE6xvD1ocHmSIu7MgzlC9woj' ,
@@ -38,7 +37,7 @@ def test_get_balance_before_first_transaction(httpx_mock: HTTPXMock):
3837 # When the user have no transactions at all
3938 # balance_entries endpoint returns `items` as empty list.
4039 # It means that its balance is Mx$0.00
41- response_json = {'items' : [], 'next_page_uri' : None }
40+ response_json : dict = {'items' : [], 'next_page_uri' : None }
4241
4342 httpx_mock .add_response (
4443 url = 'https://sandbox.cuenca.com/balance_entries?limit=1' ,
You can’t perform that action at this time.
0 commit comments