Skip to content

[Test] Add baseUrl environment tests to all service test files #475

@gcatanese

Description

@gcatanese

Context

RecurringTest.py has three tests that validate the baseUrl resolves correctly for both environments:

def test_base_url_test_environment(self):
    url = self.adyen.client._determine_api_url("test", self.baseUrl)
    self.assertEqual(url, self.baseUrl)
    self.assertTrue(url.startswith("https://pal-test.adyen.com/pal/servlet/Recurring/"))

def test_base_url_live_environment(self):
    self.adyen.client.live_endpoint_prefix = "1797a841fbb37ca7-AdyenDemo"
    recurring_version = self.baseUrl.split("/")[-1]
    url = self.adyen.client._determine_api_url("live", self.baseUrl)
    self.assertEqual(
        url,
        f"https://1797a841fbb37ca7-AdyenDemo-pal-live.adyenpayments.com"
        f"/pal/servlet/Recurring/{recurring_version}",
    )
    self.adyen.client.live_endpoint_prefix = None

def test_base_url_live_environment_no_prefix_raises(self):
    self.adyen.client.live_endpoint_prefix = None
    self.assertRaises(
        AdyenEndpointInvalidFormat,
        self.adyen.client._determine_api_url,
        "live",
        self.baseUrl,
    )

These tests are missing from all other service test files:

  • BalancePlatformTest.py
  • BinLookupTest.py
  • CapitalTest.py
  • CheckoutTest.py
  • DataProtectionTest.py
  • DisputesTest.py
  • LegalEntityManagementTest.py
  • ManagementTest.py
  • ModificationTest.py (payments)
  • PaymentTest.py
  • PosMobileTest.py
  • SessionAuthenticationTest.py
  • StoredValueTest.py
  • ThirdPartyPayoutTest.py
  • TransfersTest.py

Proposed Change

Add the equivalent of test_base_url_test_environment, test_base_url_live_environment, and test_base_url_live_environment_no_prefix_raises to each service test file, adapting the expected URLs to match the service's URL pattern (PAL, checkout, balancePlatform, management, etc.).

Note: test_base_url_live_environment_no_prefix_raises only applies to services that require a live_endpoint_prefix (i.e. PAL and checkout-based services).

Benefit

Ensures that URL resolution for both test and live environments is explicitly verified for every service, catching regressions in _determine_api_url early.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions