177
179
def put(self, filename, fileobj):
178
180
self.files[filename] = fileobj.read()
182
def put_file(self, filename, fileobj):
183
return self.put(filename, fileobj)
181
186
class InstrumentedConfig(config.Config):
182
187
"""An instrumented config that supplies stubs for template methods."""
1136
1141
self.assertEqual(value, 'value3-section')
1144
class TestTransportConfig(tests.TestCaseWithTransport):
1146
def test_get_value(self):
1147
"""Test that retreiving a value from a section is possible"""
1148
bzrdir_config = config.TransportConfig(transport.get_transport('.'),
1150
bzrdir_config.set_option('value', 'key', 'SECTION')
1151
bzrdir_config.set_option('value2', 'key2')
1152
bzrdir_config.set_option('value3-top', 'key3')
1153
bzrdir_config.set_option('value3-section', 'key3', 'SECTION')
1154
value = bzrdir_config.get_option('key', 'SECTION')
1155
self.assertEqual(value, 'value')
1156
value = bzrdir_config.get_option('key2')
1157
self.assertEqual(value, 'value2')
1158
self.assertEqual(bzrdir_config.get_option('non-existant'), None)
1159
value = bzrdir_config.get_option('non-existant', 'SECTION')
1160
self.assertEqual(value, None)
1161
value = bzrdir_config.get_option('non-existant', default='default')
1162
self.assertEqual(value, 'default')
1163
self.assertEqual(bzrdir_config.get_option('key2', 'NOSECTION'), None)
1164
value = bzrdir_config.get_option('key2', 'NOSECTION',
1166
self.assertEqual(value, 'default')
1167
value = bzrdir_config.get_option('key3')
1168
self.assertEqual(value, 'value3-top')
1169
value = bzrdir_config.get_option('key3', 'SECTION')
1170
self.assertEqual(value, 'value3-section')
1139
1173
class TestAuthenticationConfigFile(tests.TestCase):
1140
1174
"""Test the authentication.conf file matching"""