Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpack params before performing calling get_transactions and get_report #351

Merged
Merged
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
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
Loading