Skip to content

Unit test for transfer (PR485) and checkout (PR496) - #507

Merged
poojah-adyen merged 2 commits into
mainfrom
unit-test-cases-checkout-transfer
Sep 16, 2026
Merged

poojah-adyen merged 2 commits into
mainfrom
unit-test-cases-checkout-transfer

Conversation

@poojah-adyen

Copy link
Copy Markdown
Contributor

Description

Tested scenarios

Fixed issue:

@poojah-adyen
poojah-adyen requested a review from a team as a code owner September 16, 2026 08:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds new unit tests for the Adyen Python API library, including tests for checkout API versions, session updates, and cashout initiations (with idempotency key support) along with a mock JSON response. The review feedback identifies several issues: a potential AttributeError due to a missing update_session method, an API version mismatch in the checkout test assertion, and fragile base URL assertions in the transfers tests.

Comment thread test/CheckoutTest.py
session_id = "YOUR_SESSION_ID"
self.adyen.client = self.test.create_client_from_file(200, request)

self.adyen.checkout.payments_api.update_session(request, session_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The update_session method is called on payments_api, but this method is not defined in Adyen/services/checkout/payments_api.py. Running this test will result in an AttributeError. Please ensure that the update_session method is implemented in the PaymentsApi class.

Comment thread test/CheckoutTest.py

for checkout_api in checkout_apis:
with self.subTest(api=checkout_api.__class__.__name__):
self.assertEqual("https://checkout-test.adyen.com/v72", checkout_api.baseUrl)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion expects the base URL to end with /v72, but PaymentsApi is configured with /v71 in the codebase. This mismatch will cause the test to fail. Please update the assertion to /v71 or ensure the API service classes are updated to /v72.

Suggested change
self.assertEqual("https://checkout-test.adyen.com/v72", checkout_api.baseUrl)
self.assertEqual("https://checkout-test.adyen.com/v71", checkout_api.baseUrl)

Comment thread test/TransfersTest.py

self.adyen.client.http_client.request.assert_called_once_with(
"POST",
f"{self.transfers_url}/cashouts",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using self.transfers_url (which is derived from transfers_api.baseUrl) to assert the endpoint for cash_out_api is fragile and assumes both APIs share the exact same base URL. It is more robust to use self.adyen.transfers.cash_out_api.baseUrl directly.

Suggested change
f"{self.transfers_url}/cashouts",
f"{self.adyen.transfers.cash_out_api.baseUrl}/cashouts",

Comment thread test/TransfersTest.py

self.adyen.client.http_client.request.assert_called_once_with(
"POST",
f"{self.transfers_url}/cashouts",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using self.transfers_url (which is derived from transfers_api.baseUrl) to assert the endpoint for cash_out_api is fragile and assumes both APIs share the exact same base URL. It is more robust to use self.adyen.transfers.cash_out_api.baseUrl directly.

Suggested change
f"{self.transfers_url}/cashouts",
f"{self.adyen.transfers.cash_out_api.baseUrl}/cashouts",

@sonarqubecloud

Copy link
Copy Markdown

@poojah-adyen

Copy link
Copy Markdown
Contributor Author

@gemini-code-assist please look at the new changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new unit tests for checkout API versions, session updates, and cashout initiation (including idempotency key support) along with its corresponding mock response. The feedback highlights that in test_update_session, the create_client_from_file method is called without specifying the mock file path, which could cause the test to fail or not mock the response correctly.

Comment thread test/CheckoutTest.py
@poojah-adyen
poojah-adyen added this pull request to the merge queue Sep 16, 2026
Merged via the queue into main with commit 9652faa Sep 16, 2026
14 checks passed
@poojah-adyen
poojah-adyen deleted the unit-test-cases-checkout-transfer branch September 16, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants