179
179
def test_append_and_get(self):
180
180
transport = MemoryTransport()
181
transport.append('path', StringIO('content'))
181
transport.append_bytes('path', 'content')
182
182
self.assertEqual(transport.get('path').read(), 'content')
183
transport.append('path', StringIO('content'))
183
transport.append_file('path', StringIO('content'))
184
184
self.assertEqual(transport.get('path').read(), 'contentcontent')
186
186
def test_put_and_get(self):
187
187
transport = MemoryTransport()
188
transport.put('path', StringIO('content'))
188
transport.put_file('path', StringIO('content'))
189
189
self.assertEqual(transport.get('path').read(), 'content')
190
transport.put('path', StringIO('content'))
190
transport.put_bytes('path', 'content')
191
191
self.assertEqual(transport.get('path').read(), 'content')
193
193
def test_append_without_dir_fails(self):
194
194
transport = MemoryTransport()
195
195
self.assertRaises(NoSuchFile,
196
transport.append, 'dir/path', StringIO('content'))
196
transport.append_bytes, 'dir/path', 'content')
198
198
def test_put_without_dir_fails(self):
199
199
transport = MemoryTransport()
200
200
self.assertRaises(NoSuchFile,
201
transport.put, 'dir/path', StringIO('content'))
201
transport.put_file, 'dir/path', StringIO('content'))
203
203
def test_get_missing(self):
204
204
transport = MemoryTransport()
211
211
def test_has_present(self):
212
212
transport = MemoryTransport()
213
transport.append('foo', StringIO('content'))
213
transport.append_bytes('foo', 'content')
214
214
self.assertEquals(True, transport.has('foo'))
216
216
def test_mkdir(self):
217
217
transport = MemoryTransport()
218
218
transport.mkdir('dir')
219
transport.append('dir/path', StringIO('content'))
219
transport.append_bytes('dir/path', 'content')
220
220
self.assertEqual(transport.get('dir/path').read(), 'content')
222
222
def test_mkdir_missing_parent(self):
238
238
def test_iter_files_recursive(self):
239
239
transport = MemoryTransport()
240
240
transport.mkdir('dir')
241
transport.put('dir/foo', StringIO('content'))
242
transport.put('dir/bar', StringIO('content'))
243
transport.put('bar', StringIO('content'))
241
transport.put_bytes('dir/foo', 'content')
242
transport.put_bytes('dir/bar', 'content')
243
transport.put_bytes('bar', 'content')
244
244
paths = set(transport.iter_files_recursive())
245
245
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
247
247
def test_stat(self):
248
248
transport = MemoryTransport()
249
transport.put('foo', StringIO('content'))
250
transport.put('bar', StringIO('phowar'))
249
transport.put_bytes('foo', 'content')
250
transport.put_bytes('bar', 'phowar')
251
251
self.assertEqual(7, transport.stat('foo').st_size)
252
252
self.assertEqual(6, transport.stat('bar').st_size)