76
76
"""Check that transport.get(relpath).read() == content."""
77
77
self.assertEqual(content, transport.get(relpath).read())
79
def check_mode(self, transport, path, mode):
80
"""Check that a particular path has mode mode."""
81
if sys.platform == 'win32':
84
path_stat = transport.stat(path)
85
actual_mode = stat.S_IMODE(path_stat.st_mode)
86
self.assertEqual(mode, actual_mode,
87
'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
89
79
def get_transport(self):
90
80
"""Return a connected transport to the local directory."""
91
81
t = bzrlib.transport.get_transport(self._server.get_url())
188
178
if t.is_readonly():
190
180
t.put('mode644', StringIO('test text\n'), mode=0644)
191
self.check_mode(t, 'mode644', 0644)
181
self.assertMode(t, 'mode644', 0644)
192
182
t.put('mode666', StringIO('test text\n'), mode=0666)
193
self.check_mode(t, 'mode666', 0666)
183
self.assertMode(t, 'mode666', 0666)
194
184
t.put('mode600', StringIO('test text\n'), mode=0600)
195
self.check_mode(t, 'mode600', 0600)
185
self.assertMode(t, 'mode600', 0600)
196
186
# Yes, you can put a file such that it becomes readonly
197
187
t.put('mode400', StringIO('test text\n'), mode=0400)
198
self.check_mode(t, 'mode400', 0400)
188
self.assertMode(t, 'mode400', 0400)
199
189
t.put_multi([('mmode644', StringIO('text\n'))], mode=0644)
200
self.check_mode(t, 'mmode644', 0644)
190
self.assertMode(t, 'mmode644', 0644)
202
192
def test_mkdir(self):
203
193
t = self.get_transport()
254
244
# Test mkdir with a mode
255
245
t.mkdir('dmode755', mode=0755)
256
self.check_mode(t, 'dmode755', 0755)
246
self.assertMode(t, 'dmode755', 0755)
257
247
t.mkdir('dmode555', mode=0555)
258
self.check_mode(t, 'dmode555', 0555)
248
self.assertMode(t, 'dmode555', 0555)
259
249
t.mkdir('dmode777', mode=0777)
260
self.check_mode(t, 'dmode777', 0777)
250
self.assertMode(t, 'dmode777', 0777)
261
251
t.mkdir('dmode700', mode=0700)
262
self.check_mode(t, 'dmode700', 0700)
252
self.assertMode(t, 'dmode700', 0700)
263
253
# TODO: jam 20051215 test mkdir_multi with a mode
264
254
t.mkdir_multi(['mdmode755'], mode=0755)
265
self.check_mode(t, 'mdmode755', 0755)
255
self.assertMode(t, 'mdmode755', 0755)
267
257
def test_copy_to(self):
268
258
from bzrlib.transport.memory import MemoryTransport
304
294
temp_transport = MemoryTransport("memory:/")
305
295
t.copy_to(files, temp_transport, mode=mode)
307
self.check_mode(temp_transport, f, mode)
297
self.assertMode(temp_transport, f, mode)
309
299
def test_append(self):
310
300
t = self.get_transport()