- Timestamp:
- 20 Nov 2014, 03:06:02 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py
r11998 r11999 1 import os 1 2 import tempfile 2 3 import shutil … … 51 52 gsm.unregisterUtility(conf, iface) 52 53 54 def create_fake_paypal_configs(self): 55 # create two regular files in workdir 56 self.conf1_path = os.path.join(self.workdir, 'paypal1.conf') 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') 60 53 61 def test_datacenter_config_directive(self): 54 62 # the 'datacenter' directive can be used in ZCML … … 71 79 # the 'paypalconf' ZCML directive works 72 80 assert queryUtility(IPayPalConfig) is None 73 zcfile("sample-paypalconf.zcml", tests) # 'execute' the ZCML file 81 self.create_fake_paypal_configs() 82 config = get_zcml_conf( 83 '<ikoba:paypalconf path="%s" />' % self.conf1_path 84 ) 85 zcstring(config) # execute ZCML 74 86 result = getUtility(IPayPalConfig) 75 assert result == {'path': u'/path/to/some/paypal.conf'}87 assert result == {'path': self.conf1_path} 76 88 77 89 def test_paypal_config_singleton(self): 78 90 # we can define only one paypal config 91 assert queryUtility(IPayPalConfig) is None 92 self.create_fake_paypal_configs() 79 93 config = get_zcml_conf( 80 '<ikoba:paypalconf path=" /some/path" />'81 '<ikoba:paypalconf path=" /other/path" />'82 ) 94 '<ikoba:paypalconf path="%s" />' 95 '<ikoba:paypalconf path="%s" />' 96 ) % (self.conf1_path, self.conf2_path) 83 97 assert queryUtility(IPayPalConfig) is None 84 98 self.assertRaises( 85 99 ConfigurationError, zcstring, config) 100 101 def test_paypal_config_no_such_file(self): 102 # a set paypal config file must exist 103 config = get_zcml_conf( 104 '<ikoba:paypalconf path="/not/eXiStInG/path" />') 105 self.assertRaises( 106 ConfigurationError, zcstring, config) 107 108 def test_paypal_config_not_a_regular_file(self): 109 # a paypal config file must be a regular file 110 dirpath = os.path.join(self.workdir, 'mydir') 111 os.mkdir(dirpath) 112 config = get_zcml_conf( 113 '<ikoba:paypalconf path="%s" />' % dirpath) 114 self.assertRaises( 115 ConfigurationError, zcstring, config)
Note: See TracChangeset for help on using the changeset viewer.