185
185
def test_append_and_get(self):
186
186
transport = MemoryTransport()
187
transport.append('path', StringIO('content'))
187
transport.append_bytes('path', 'content')
188
188
self.assertEqual(transport.get('path').read(), 'content')
189
transport.append('path', StringIO('content'))
189
transport.append_file('path', StringIO('content'))
190
190
self.assertEqual(transport.get('path').read(), 'contentcontent')
192
192
def test_put_and_get(self):
193
193
transport = MemoryTransport()
194
transport.put('path', StringIO('content'))
194
transport.put_file('path', StringIO('content'))
195
195
self.assertEqual(transport.get('path').read(), 'content')
196
transport.put('path', StringIO('content'))
196
transport.put_bytes('path', 'content')
197
197
self.assertEqual(transport.get('path').read(), 'content')
199
199
def test_append_without_dir_fails(self):
200
200
transport = MemoryTransport()
201
201
self.assertRaises(NoSuchFile,
202
transport.append, 'dir/path', StringIO('content'))
202
transport.append_bytes, 'dir/path', 'content')
204
204
def test_put_without_dir_fails(self):
205
205
transport = MemoryTransport()
206
206
self.assertRaises(NoSuchFile,
207
transport.put, 'dir/path', StringIO('content'))
207
transport.put_file, 'dir/path', StringIO('content'))
209
209
def test_get_missing(self):
210
210
transport = MemoryTransport()
217
217
def test_has_present(self):
218
218
transport = MemoryTransport()
219
transport.append('foo', StringIO('content'))
219
transport.append_bytes('foo', 'content')
220
220
self.assertEquals(True, transport.has('foo'))
222
222
def test_mkdir(self):
223
223
transport = MemoryTransport()
224
224
transport.mkdir('dir')
225
transport.append('dir/path', StringIO('content'))
225
transport.append_bytes('dir/path', 'content')
226
226
self.assertEqual(transport.get('dir/path').read(), 'content')
228
228
def test_mkdir_missing_parent(self):
244
244
def test_iter_files_recursive(self):
245
245
transport = MemoryTransport()
246
246
transport.mkdir('dir')
247
transport.put('dir/foo', StringIO('content'))
248
transport.put('dir/bar', StringIO('content'))
249
transport.put('bar', StringIO('content'))
247
transport.put_bytes('dir/foo', 'content')
248
transport.put_bytes('dir/bar', 'content')
249
transport.put_bytes('bar', 'content')
250
250
paths = set(transport.iter_files_recursive())
251
251
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
253
253
def test_stat(self):
254
254
transport = MemoryTransport()
255
transport.put('foo', StringIO('content'))
256
transport.put('bar', StringIO('phowar'))
255
transport.put_bytes('foo', 'content')
256
transport.put_bytes('bar', 'phowar')
257
257
self.assertEqual(7, transport.stat('foo').st_size)
258
258
self.assertEqual(6, transport.stat('bar').st_size)