Repository navigation
Unit test for transfer (PR485) and checkout (PR496) #507
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,21 @@ class TestCheckout(unittest.TestCase): | |
| baseUrl = adyen.checkout.payments_api.baseUrl | ||
| lib_version = settings.LIB_VERSION | ||
|
|
||
| def test_checkout_api_version(self): | ||
| checkout_apis = ( | ||
| self.adyen.checkout.donations_api, | ||
| self.adyen.checkout.modifications_api, | ||
| self.adyen.checkout.orders_api, | ||
| self.adyen.checkout.payment_links_api, | ||
| self.adyen.checkout.payments_api, | ||
| self.adyen.checkout.recurring_api, | ||
| self.adyen.checkout.utility_api, | ||
| ) | ||
|
|
||
| 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) | ||
|
|
||
| def test_payment_methods_success_mocked(self): | ||
| request = {"merchantAccount": "YourMerchantAccount"} | ||
| self.adyen.client = self.test.create_client_from_file( | ||
|
|
@@ -438,6 +453,25 @@ def test_sessions_error(self): | |
| self.assertEqual("130", result.message["errorCode"]) | ||
| self.assertEqual("validation", result.message["errorType"]) | ||
|
|
||
| def test_update_session(self): | ||
| request = {"amount": {"currency": "EUR", "value": 1000}} | ||
| session_id = "YOUR_SESSION_ID" | ||
| self.adyen.client = self.test.create_client_from_file(200, request) | ||
|
poojah-adyen marked this conversation as resolved.
|
||
|
|
||
| self.adyen.checkout.payments_api.update_session(request, session_id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| self.adyen.client.http_client.request.assert_called_once_with( | ||
| "PATCH", | ||
| f"{self.baseUrl}/sessions/{session_id}", | ||
| headers={ | ||
| "adyen-library-name": "adyen-python-api-library", | ||
| "adyen-library-version": settings.LIB_VERSION, | ||
| "User-Agent": "adyen-python-api-library/" + settings.LIB_VERSION, | ||
| }, | ||
| json=request, | ||
| xapikey="YourXapikey", | ||
| ) | ||
|
|
||
| def test_payment_link(self): | ||
| request = { | ||
| "reference": "YOUR_ORDER_NUMBER", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,3 +103,62 @@ def test_get_transaction(self): | |||||
| json=None, | ||||||
| xapikey="YourXapikey", | ||||||
| ) | ||||||
|
|
||||||
| def test_initiate_cashout(self): | ||||||
| request = { | ||||||
| "instructingBalanceAccountId": "BA00000000000000000000001", | ||||||
| "amount": {"currency": "EUR", "value": 50000}, | ||||||
| "counterparty": {"transferInstrumentId": "SE00000000000000000000001"}, | ||||||
| "description": "Cashout to bank account", | ||||||
| "referenceForBeneficiary": "CASHOUT-REF-001", | ||||||
| "fee": {"amount": {"currency": "EUR", "value": 500}}, | ||||||
| } | ||||||
| self.adyen.client = self.test.create_client_from_file( | ||||||
| 200, request, "test/mocks/transfers/initiate-cashout.json" | ||||||
| ) | ||||||
| result = self.adyen.transfers.cash_out_api.initiate_cashout(request) | ||||||
| self.assertIsNotNone(result) | ||||||
| self.assertEqual("CO00000000000000000000001", result.message["id"]) | ||||||
| self.assertEqual(50000, result.message["amount"]["value"]) | ||||||
| self.assertEqual( | ||||||
| ["cashoutRepayment", "cashoutFee"], | ||||||
| [transfer["type"] for transfer in result.message["transfers"]], | ||||||
| ) | ||||||
|
|
||||||
| self.adyen.client.http_client.request.assert_called_once_with( | ||||||
| "POST", | ||||||
| f"{self.transfers_url}/cashouts", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||
| headers={ | ||||||
| "adyen-library-name": "adyen-python-api-library", | ||||||
| "adyen-library-version": settings.LIB_VERSION, | ||||||
| "User-Agent": "adyen-python-api-library/" + settings.LIB_VERSION, | ||||||
| }, | ||||||
| json=request, | ||||||
| xapikey="YourXapikey", | ||||||
| ) | ||||||
|
|
||||||
| def test_initiate_cashout_idempotency_key(self): | ||||||
| request = { | ||||||
| "instructingBalanceAccountId": "BA00000000000000000000001", | ||||||
| "amount": {"currency": "EUR", "value": 50000}, | ||||||
| "counterparty": {"transferInstrumentId": "SE00000000000000000000001"}, | ||||||
| } | ||||||
| self.adyen.client = self.test.create_client_from_file( | ||||||
| 200, request, "test/mocks/transfers/initiate-cashout.json" | ||||||
| ) | ||||||
| self.adyen.transfers.cash_out_api.initiate_cashout( | ||||||
| request, idempotency_key="test-idempotency-key-001" | ||||||
| ) | ||||||
|
|
||||||
| self.adyen.client.http_client.request.assert_called_once_with( | ||||||
| "POST", | ||||||
| f"{self.transfers_url}/cashouts", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||
| headers={ | ||||||
| "adyen-library-name": "adyen-python-api-library", | ||||||
| "adyen-library-version": settings.LIB_VERSION, | ||||||
| "User-Agent": "adyen-python-api-library/" + settings.LIB_VERSION, | ||||||
| "Idempotency-Key": "test-idempotency-key-001", | ||||||
| }, | ||||||
| json=request, | ||||||
| xapikey="YourXapikey", | ||||||
| ) | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "id": "CO00000000000000000000001", | ||
| "instructingBalanceAccountId": "BA00000000000000000000001", | ||
| "amount": { | ||
| "currency": "EUR", | ||
| "value": 50000 | ||
| }, | ||
| "counterparty": { | ||
| "transferInstrumentId": "SE00000000000000000000001" | ||
| }, | ||
| "description": "Cashout to bank account", | ||
| "referenceForBeneficiary": "CASHOUT-REF-001", | ||
| "fee": { | ||
| "amount": { | ||
| "currency": "EUR", | ||
| "value": 500 | ||
| } | ||
| }, | ||
| "transfers": [ | ||
| { | ||
| "id": "400F6060JMB1I0AB", | ||
| "type": "cashoutRepayment", | ||
| "amount": { | ||
| "currency": "EUR", | ||
| "value": 50500 | ||
| } | ||
| }, | ||
| { | ||
| "id": "400F6060JMB1I0AA", | ||
| "type": "cashoutFee", | ||
| "amount": { | ||
| "currency": "EUR", | ||
| "value": 500 | ||
| } | ||
| } | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion expects the base URL to end with
/v72, butPaymentsApiis configured with/v71in the codebase. This mismatch will cause the test to fail. Please update the assertion to/v71or ensure the API service classes are updated to/v72.