Skip to content

Commit

Permalink
Merge pull request #351 from rubenhesselink/fix-get-transactions-params
Browse files Browse the repository at this point in the history
Unpack params before performing calling get_transactions and get_report
  • Loading branch information
geertjanvdenbosch committed Jul 24, 2024
2 parents aedc634 + 55cbdd5 commit 5a11cd2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mollie/api/objects/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def pending_amount(self):
def get_report(self, **params: Any) -> BalanceReport:
from ..resources import BalanceReports

return BalanceReports(self.client, self).get_report(params=params)
return BalanceReports(self.client, self).get_report(**params)

def get_transactions(self, **params: Any) -> PaginationList:
from ..resources import BalanceTransactions

return BalanceTransactions(self.client, self).list(params=params)
return BalanceTransactions(self.client, self).list(**params)
23 changes: 23 additions & 0 deletions tests/test_balances.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

import pytest

from mollie.api.error import IdentifierError
Expand Down Expand Up @@ -95,6 +97,27 @@ def test_get_balance_transactions(client, response):
assert balance_transaction.context == {"paymentId": "tr_7UhSN1zuXS", "refundId": "re_4qqhO89gsT"}


def test_get_balance_transactions_with_params(client, response):
"""Get a list of balance transactions with parameters."""
response.get(f"https://api.mollie.com/v2/balances/{BALANCE_ID}", "balance_single")

balance = client.balances.get(BALANCE_ID)
params = {"limit": 5, "sort": "asc"}

with patch("mollie.api.resources.base.ResourceListMixin.perform_api_call") as mock_perform_api_call:
balance.get_transactions(**params)

# Assert perform_api_call was called
mock_perform_api_call.assert_called_once()

# Extract the parameters passed to perform_api_call
_, called_kwargs = mock_perform_api_call.call_args
called_params = called_kwargs.get("params")

# Assert the params are what we expect
assert called_params == params


def test_get_balance_invalid_id(client):
"""Test that the balance ID is validated upon retrieving a balance.
Expand Down

0 comments on commit 5a11cd2

Please sign in to comment.