Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion revolut/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _request(self, func, path, data=None):
if rsp.status_code != 204:
result = rsp.json(parse_float=Decimal)
if rsp.status_code < 200 or rsp.status_code >= 300:
message = getattr(result, "message", "No message supplied")
message = result.get("message", "No message supplied")
_log.error("HTTP {} for {}: {}".format(rsp.status_code, url, message))
if rsp.status_code in (400, 422):
if "o pocket found" in message:
Expand Down
2 changes: 1 addition & 1 deletion revolut/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def counterparties(self):
return self._counterparties

def _refresh_counterparties(self):
self._counterparties = self._cptbyaccount = {}
self._counterparties = self._cptbyaccount = None
_ = self.counterparties

def transactions(
Expand Down
8 changes: 5 additions & 3 deletions tests/test_business.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_refresh_token_via_renewable_session(self):
self.assertIsNotNone(sess.access_token)
self.assertIn("grant_type=refresh_token", responses.calls[0].request.body)


class TestRevolutBusiness(TestCase, JSONResponsesMixin):
access_token = "oa_sand_lI35rv-tpvl0qsKa5OJGW5yiiXtKg7uZYB6b0jmLSCk"

Expand All @@ -67,16 +66,19 @@ def test_key(self):

@responses.activate
def test_404(self):
message = "The requested resource not found"
responses.add(
responses.GET,
"https://sandbox-b2b.revolut.com/api/1.0/whatever",
json={"message": "The requested resource not found"},
json={"message": message},
status=404,
)

tssn = TemporarySession(self.access_token)
cli = BusinessClient(tssn)
self.assertRaises(exceptions.RevolutHttpError, cli._get, "whatever")
with self.assertRaises(exceptions.RevolutHttpError) as cm:
cli._get("whatever")
self.assertEqual(str(cm.exception), message)

@responses.activate
def test_accounts(self):
Expand Down