Changeset 12030 for main/waeup.ikoba/branches/uli-payments/src
- Timestamp:
- 21 Nov 2014, 13:09:24 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py
r11999 r12030 56 56 self.conf1_path = os.path.join(self.workdir, 'paypal1.conf') 57 57 self.conf2_path = os.path.join(self.workdir, 'paypal2.conf') 58 open(self.conf1_path, 'w').write(' Fake')59 open(self.conf2_path, 'w').write(' Fake')58 open(self.conf1_path, 'w').write('[rest-client]\n') 59 open(self.conf2_path, 'w').write('[rest-client]\n') 60 60 61 61 def test_datacenter_config_directive(self): … … 85 85 zcstring(config) # execute ZCML 86 86 result = getUtility(IPayPalConfig) 87 assert result == {'path': self.conf1_path} 87 assert result == { 88 'path': self.conf1_path, 89 'client_id': None, 90 'client_secret': None, 91 'mode': 'sandbox' 92 } 88 93 89 94 def test_paypal_config_singleton(self): -
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py
r11999 r12030 20 20 from zope.configuration.exceptions import ConfigurationError 21 21 from waeup.ikoba.interfaces import IDataCenterConfig, IPayPalConfig 22 from waeup.ikoba.payments.paypal import configure_sdk 22 23 23 24 … … 59 60 We expect paypal credentials written down in a config file. The 60 61 path to this config file can be set with the ZCML `paypalconf` 61 directive, which is handled here. 62 directive, which is handled here and looks like this:: 63 64 <ikoba:paypalconf path='/some/path/to/paypal.conf' /> 62 65 63 66 This handler requires the given path to exist and to be a file. 64 67 65 If the file exists and is readable, a dict with ``path`` set to66 the given path is registered as a global unnamed utility for the67 `IPayPalConfig` interface.68 If the file exists and is readable, a dict with ``path`` and other 69 values read from the configuration file is registered as a global 70 unnamed utility for the `IPayPalConfig` interface. 68 71 69 We do not check more (syntax, etc. of a found config) as this is 70 beyond the scope of ZCML configuration. ZCML is responsible for 71 finding _some_ paypal configuration file, not for the values found 72 (or not found) within this file. 72 See :func:`waeup.ikoba.payments.paypal.configure_sdk for details 73 of the set dict. 73 74 """ 74 75 if not os.path.exists(path): … … 76 77 if not os.path.isfile(path): 77 78 raise ConfigurationError("Not a regular file: %s" % path) 79 config_dict = configure_sdk(path) 78 80 return handler( 79 'registerUtility', {'path': path}, IPayPalConfig, '')81 'registerUtility', config_dict, IPayPalConfig, '') 80 82 81 83
Note: See TracChangeset for help on using the changeset viewer.