diff --git a/Adyen/services/base.py b/Adyen/services/base.py index 2f4a20d4..e4923481 100644 --- a/Adyen/services/base.py +++ b/Adyen/services/base.py @@ -14,6 +14,9 @@ def __getattr__(self, attr): client_attr = ["username", "password", "platform"] if attr in client_attr: return self.client[attr] + raise AttributeError( + f"'{self.__class__.__name__}' object has no attribute '{attr}'" + ) class AdyenServiceBase(AdyenBase): diff --git a/test/ClientTest.py b/test/ClientTest.py index d0b8c195..831a7a40 100644 --- a/test/ClientTest.py +++ b/test/ClientTest.py @@ -17,3 +17,11 @@ class TestClient(unittest.TestCase): client.xapikey = "YOUR_API_KEY" client.platform = "test" lib_version = settings.LIB_VERSION + + def test_unknown_properties_raise_attribute_error(self): + with self.assertRaises(AttributeError): + _ = self.adyen.foobar + # Resolve parent attributes outside of assertRaises to avoid false positives + payments_api = self.adyen.payment.payments_api + with self.assertRaises(AttributeError): + _ = payments_api.foobar