Repository navigation
Unit test for transfer (PR485) and checkout (PR496) - #507
Conversation
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
|
|
||
| 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) |
There was a problem hiding this comment.
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.
| self.assertEqual("https://checkout-test.adyen.com/v72", checkout_api.baseUrl) | |
| self.assertEqual("https://checkout-test.adyen.com/v71", checkout_api.baseUrl) |
|
|
||
| self.adyen.client.http_client.request.assert_called_once_with( | ||
| "POST", | ||
| f"{self.transfers_url}/cashouts", |
There was a problem hiding this comment.
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.
| f"{self.transfers_url}/cashouts", | |
| f"{self.adyen.transfers.cash_out_api.baseUrl}/cashouts", |
|
|
||
| self.adyen.client.http_client.request.assert_called_once_with( | ||
| "POST", | ||
| f"{self.transfers_url}/cashouts", |
There was a problem hiding this comment.
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.
| f"{self.transfers_url}/cashouts", | |
| f"{self.adyen.transfers.cash_out_api.baseUrl}/cashouts", |
|
|
@gemini-code-assist please look at the new changes |
There was a problem hiding this comment.
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.



Description
Tested scenarios
Fixed issue: