Skip to content

Commit

Permalink
up coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rogelioLpz committed May 14, 2020
1 parent 447e692 commit 57dea95
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cuenca/version.py
@@ -1,3 +1,3 @@
__version__ = '0.0.1dev0'
__version__ = '0.0.2dev0'
CLIENT_VERSION = __version__
API_VERSION = '2020-03-19'
Empty file added tests/http/__init__.py
Empty file.
@@ -1,6 +1,6 @@
interactions:
- request:
body: null
body: '{}'
headers:
Accept:
- '*/*'
Expand All @@ -10,12 +10,16 @@ interactions:
- DUMMY
Connection:
- keep-alive
Content-Length:
- '2'
Content-Type:
- application/json
User-Agent:
- cuenca-python/0.0.1dev0
- cuenca-python/0.0.2dev0
X-Cuenca-Api-Version:
- '2020-03-19'
method: GET
uri: https://sandbox.cuenca.com/transfers?limit=2
method: POST
uri: https://api.cuenca.com/api_keys
response:
body:
string: '{"Code":"UnauthorizedError","Message":"UnauthorizedError: Wrong creds"}'
Expand All @@ -27,21 +31,21 @@ interactions:
Content-Type:
- application/json
Date:
- Mon, 11 May 2020 22:15:24 GMT
- Thu, 14 May 2020 03:30:43 GMT
Via:
- 1.1 430c98a561662ce110d7e2e105bbcbed.cloudfront.net (CloudFront)
- 1.1 5c58021efde9831dc4a4b288db2f5256.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- 3AIlvPT3g90NXxXTDYT8hhGQRp-bgJP4WDhDQJ9qBVbvX8gPQGmMig==
- rCbapXA22ztNBD-TrY9YvjAWupeTqPLuiBoGyX4qh9xz44U5y6rp1w==
X-Amz-Cf-Pop:
- DFW3-C1
X-Amzn-Trace-Id:
- Root=1-5eb9ce7c-a6858671b640fa3767416ca3;Sampled=0
- Root=1-5ebcbb61-a371ad289b02ea22a93466be;Sampled=0
X-Cache:
- Error from cloudfront
x-amz-apigw-id:
- MY0zhHwEIAMFf6Q=
- MgI3QHg-oAMFykQ=
x-amzn-RequestId:
- 606fa6b6-987b-4c54-b6ee-2e5820227e10
- a099594c-cec8-4459-9330-c68db0a34841
status:
code: 401
message: Unauthorized
Expand Down
12 changes: 12 additions & 0 deletions tests/http/test_client.py
@@ -0,0 +1,12 @@
import pytest
from requests import HTTPError

from cuenca.http import session


@pytest.mark.vcr
def test_invalid_auth():
session.configure(sandbox=False)
with pytest.raises(HTTPError):
session.post('/api_keys', dict())
session.configure(sandbox=True)
15 changes: 15 additions & 0 deletions tests/resources/test_api_keys.py
Expand Up @@ -63,3 +63,18 @@ def test_api_key_to_dict():
)

assert api_key_dict == api_key.to_dict()


def test_api_key_from_dict():
api_keys_dict = dict(
id='123455',
secret='*********',
created_at=dt.datetime.utcnow(),
deactivated_at=None,
extra_field_1='not necessary',
extra_field_2=12345,
)
api_key = ApiKey._from_dict(api_keys_dict)
assert not hasattr(api_key, 'extra_field_1')
assert not hasattr(api_key, 'extra_field_2')
assert api_key.id is not None
8 changes: 1 addition & 7 deletions tests/resources/test_transfers.py
@@ -1,5 +1,4 @@
import pytest
from requests import HTTPError

from cuenca import Transfer
from cuenca.exc import MultipleResultsFound, NoResultFound
Expand Down Expand Up @@ -77,11 +76,6 @@ def test_transfers_count():
assert count == 4


@pytest.mark.vcr
def test_client_errors():
# Invalid params
def test_invalid_params():
with pytest.raises(ValueError):
Transfer.one(invalid_param='invalid_param')
# Unauthorized client
with pytest.raises(HTTPError):
Transfer.one()

0 comments on commit 57dea95

Please sign in to comment.