Created a seperate arvados-fuse-driver package.
[arvados.git] / sdk / python / test_collections.py
1 # usage example:
2 #
3 # ARVADOS_API_TOKEN=abc ARVADOS_API_HOST=arvados.local python -m unittest discover
4
5 import unittest
6 import arvados
7 import os
8 import bz2
9 import sys
10 import subprocess
11
12 class KeepLocalStoreTest(unittest.TestCase):
13     def setUp(self):
14         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
15     def runTest(self):
16         self.assertEqual(arvados.Keep.put('foo'), 'acbd18db4cc2f85cedef654fccc4a4d8+3', 'wrong md5 hash from Keep.put')
17         self.assertEqual(arvados.Keep.get('acbd18db4cc2f85cedef654fccc4a4d8+3'), 'foo', 'wrong data from Keep.get')
18
19 class LocalCollectionWriterTest(unittest.TestCase):
20     def setUp(self):
21         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
22     def runTest(self):
23         cw = arvados.CollectionWriter()
24         self.assertEqual(cw.current_stream_name(), '.',
25                          'current_stream_name() should be "." now')
26         cw.set_current_file_name('foo.txt')
27         cw.write('foo')
28         self.assertEqual(cw.current_file_name(), 'foo.txt',
29                          'current_file_name() should be foo.txt now')
30         cw.start_new_file('bar.txt')
31         cw.write('bar')
32         cw.start_new_stream('baz')
33         cw.write('baz')
34         cw.set_current_file_name('baz.txt')
35         hash = cw.finish()
36         self.assertEqual(hash,
37                          'd6c3b8e571f1b81ebb150a45ed06c884+114',
38                          "resulting manifest hash was {0}, expecting d6c3b8e571f1b81ebb150a45ed06c884+114".format(hash))
39
40 class LocalCollectionReaderTest(unittest.TestCase):
41     def setUp(self):
42         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
43         LocalCollectionWriterTest().runTest()
44     def runTest(self):
45         cr = arvados.CollectionReader('d6c3b8e571f1b81ebb150a45ed06c884+114+Xzizzle')
46         got = []
47         for s in cr.all_streams():
48             for f in s.all_files():
49                 got += [[f.size(), f.stream_name(), f.name(), f.read(2**26)]]
50         expected = [[3, '.', 'bar.txt', 'bar'],
51                     [3, '.', 'foo.txt', 'foo'],
52                     [3, './baz', 'baz.txt', 'baz']]
53         self.assertEqual(got,
54                          expected)
55         stream0 = cr.all_streams()[0]
56         self.assertEqual(stream0.readfrom(0, 0),
57                          '',
58                          'reading zero bytes should have returned empty string')
59         self.assertEqual(stream0.readfrom(0, 2**26),
60                          'foobar',
61                          'reading entire stream failed')
62         self.assertEqual(stream0.readfrom(2**26, 0),
63                          '',
64                          'reading zero bytes should have returned empty string')
65
66 class LocalCollectionManifestSubsetTest(unittest.TestCase):
67     def setUp(self):
68         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
69         LocalCollectionWriterTest().runTest()
70     def runTest(self):
71         self._runTest('d6c3b8e571f1b81ebb150a45ed06c884+114',
72                       [[3, '.',     'bar.txt', 'bar'],
73                        [3, '.',     'foo.txt', 'foo'],
74                        [3, './baz', 'baz.txt', 'baz']])
75         self._runTest((". %s %s 0:3:foo.txt 3:3:bar.txt\n" %
76                        (arvados.Keep.put("foo"),
77                         arvados.Keep.put("bar"))),
78                       [[3, '.', 'bar.txt', 'bar'],
79                        [3, '.', 'foo.txt', 'foo']])
80         self._runTest((". %s %s 0:2:fo.txt 2:4:obar.txt\n" %
81                        (arvados.Keep.put("foo"),
82                         arvados.Keep.put("bar"))),
83                       [[2, '.', 'fo.txt', 'fo'],
84                        [4, '.', 'obar.txt', 'obar']])
85         self._runTest((". %s %s 0:2:fo.txt 2:0:zero.txt 2:2:ob.txt 4:2:ar.txt\n" %
86                        (arvados.Keep.put("foo"),
87                         arvados.Keep.put("bar"))),
88                       [[2, '.', 'ar.txt', 'ar'],
89                        [2, '.', 'fo.txt', 'fo'],                       
90                        [2, '.', 'ob.txt', 'ob'],
91                        [0, '.', 'zero.txt', '']])
92
93     def _runTest(self, collection, expected):
94         cr = arvados.CollectionReader(collection)
95         for s in cr.all_streams():
96             for ex in expected:
97                 if ex[0] == s:
98                     f = s.files()[ex[2]]
99                     got = [f.size(), f.stream_name(), f.name(), "".join(f.readall(2**26))]
100                     self.assertEqual(got,
101                                      ex,
102                                      'all_files|as_manifest did not preserve manifest contents: got %s expected %s' % (got, ex))
103
104 class LocalCollectionReadlineTest(unittest.TestCase):
105     def setUp(self):
106         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
107     def _runTest(self, what_in, what_out):
108         cw = arvados.CollectionWriter()
109         cw.start_new_file('test.txt')
110         cw.write(what_in)
111         test1 = cw.finish()
112         cr = arvados.CollectionReader(test1)
113         got = []
114         for x in list(cr.all_files())[0].readlines():
115             got += [x]
116         self.assertEqual(got,
117                          what_out,
118                          "readlines did not split lines correctly: %s" % got)
119     def runTest(self):
120         self._runTest("\na\nbcd\n\nefg\nz",
121                       ["\n", "a\n", "bcd\n", "\n", "efg\n", "z"])
122         self._runTest("ab\ncd\n",
123                       ["ab\n", "cd\n"])
124
125 class LocalCollectionEmptyFileTest(unittest.TestCase):
126     def setUp(self):
127         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
128     def runTest(self):
129         cw = arvados.CollectionWriter()
130         cw.start_new_file('zero.txt')
131         cw.write('')
132
133         self.assertEqual(cw.manifest_text(), ". 0:0:zero.txt\n")
134         self.check_manifest_file_sizes(cw.manifest_text(), [0])
135         cw = arvados.CollectionWriter()
136         cw.start_new_file('zero.txt')
137         cw.write('')
138         cw.start_new_file('one.txt')
139         cw.write('1')
140         cw.start_new_stream('foo')
141         cw.start_new_file('zero.txt')
142         cw.write('')
143         self.check_manifest_file_sizes(cw.manifest_text(), [1,0,0])
144
145     def check_manifest_file_sizes(self, manifest_text, expect_sizes):
146         cr = arvados.CollectionReader(manifest_text)
147         got_sizes = []
148         for f in cr.all_files():
149             got_sizes += [f.size()]
150         self.assertEqual(got_sizes, expect_sizes, "got wrong file sizes %s, expected %s" % (got_sizes, expect_sizes))
151
152 class LocalCollectionBZ2DecompressionTest(unittest.TestCase):
153     def setUp(self):
154         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
155     def runTest(self):
156         n_lines_in = 2**18
157         data_in = "abc\n"
158         for x in xrange(0, 18):
159             data_in += data_in
160         compressed_data_in = bz2.compress(data_in)
161         cw = arvados.CollectionWriter()
162         cw.start_new_file('test.bz2')
163         cw.write(compressed_data_in)
164         bz2_manifest = cw.manifest_text()
165
166         cr = arvados.CollectionReader(bz2_manifest)
167
168         got = 0
169         for x in list(cr.all_files())[0].readlines():
170             self.assertEqual(x, "abc\n", "decompression returned wrong data: %s" % x)
171             got += 1
172         self.assertEqual(got,
173                          n_lines_in,
174                          "decompression returned %d lines instead of %d" % (got, n_lines_in))
175
176 class LocalCollectionGzipDecompressionTest(unittest.TestCase):
177     def setUp(self):
178         os.environ['KEEP_LOCAL_STORE'] = '/tmp'
179     def runTest(self):
180         n_lines_in = 2**18
181         data_in = "abc\n"
182         for x in xrange(0, 18):
183             data_in += data_in
184         p = subprocess.Popen(["gzip", "-1cn"],
185                              stdout=subprocess.PIPE,
186                              stdin=subprocess.PIPE,
187                              stderr=subprocess.PIPE,
188                              shell=False, close_fds=True)
189         compressed_data_in, stderrdata = p.communicate(data_in)
190
191         cw = arvados.CollectionWriter()
192         cw.start_new_file('test.gz')
193         cw.write(compressed_data_in)
194         gzip_manifest = cw.manifest_text()
195
196         cr = arvados.CollectionReader(gzip_manifest)
197         got = 0
198         for x in list(cr.all_files())[0].readlines():
199             self.assertEqual(x, "abc\n", "decompression returned wrong data: %s" % x)
200             got += 1
201         self.assertEqual(got,
202                          n_lines_in,
203                          "decompression returned %d lines instead of %d" % (got, n_lines_in))
204
205 class NormalizedCollectionTest(unittest.TestCase):
206     def runTest(self):
207         m1 = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
208 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md5sum.txt
209 . 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md5sum.txt"""
210         self.assertEqual(arvados.CollectionReader(m1).manifest_text(),
211                          """. 5348b82a029fd9e971a811ce1f71360b+43 085c37f02916da1cad16f93c54d899b7+41 8b22da26f9f433dea0a10e5ec66d73ba+43 0:127:md5sum.txt
212 """)
213
214         m2 = """. 204e43b8a1185621ca55a94839582e6f+67108864 b9677abbac956bd3e86b1deb28dfac03+67108864 fc15aff2a762b13f521baf042140acec+67108864 323d2a3ce20370c4ca1d3462a344f8fd+25885655 0:227212247:var-GS000016015-ASM.tsv.bz2
215 """
216         self.assertEqual(arvados.CollectionReader(m2).manifest_text(), m2)
217
218         m3 = """. 5348b82a029fd9e971a811ce1f71360b+43 3:40:md5sum.txt
219 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md5sum.txt
220 . 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md5sum.txt"""
221         self.assertEqual(arvados.CollectionReader(m3).manifest_text(),
222                          """. 5348b82a029fd9e971a811ce1f71360b+43 085c37f02916da1cad16f93c54d899b7+41 8b22da26f9f433dea0a10e5ec66d73ba+43 3:124:md5sum.txt
223 """)
224
225         m4 = """. 204e43b8a1185621ca55a94839582e6f+67108864 0:3:foo/bar
226 ./zzz 204e43b8a1185621ca55a94839582e6f+67108864 0:999:zzz
227 ./foo 323d2a3ce20370c4ca1d3462a344f8fd+25885655 0:3:bar"""
228         self.assertEqual(arvados.CollectionReader(m4).manifest_text(),
229                          """./foo 204e43b8a1185621ca55a94839582e6f+67108864 323d2a3ce20370c4ca1d3462a344f8fd+25885655 0:3:bar 67108864:3:bar
230 ./zzz 204e43b8a1185621ca55a94839582e6f+67108864 0:999:zzz
231 """)
232
233         m5 = """. 204e43b8a1185621ca55a94839582e6f+67108864 0:3:foo/bar
234 ./zzz 204e43b8a1185621ca55a94839582e6f+67108864 0:999:zzz
235 ./foo 204e43b8a1185621ca55a94839582e6f+67108864 3:3:bar"""
236         self.assertEqual(arvados.CollectionReader(m5).manifest_text(),
237                          """./foo 204e43b8a1185621ca55a94839582e6f+67108864 0:6:bar
238 ./zzz 204e43b8a1185621ca55a94839582e6f+67108864 0:999:zzz
239 """)
240
241         with open('testdata/1000G_ref_manifest') as f6:
242             m6 = f6.read()
243             self.assertEqual(arvados.CollectionReader(m6).manifest_text(), m6)
244
245         with open('testdata/jlake_manifest') as f7:
246             m7 = f7.read()
247             self.assertEqual(arvados.CollectionReader(m7).manifest_text(), m7)
248
249         m8 = """./a\\040b\\040c 59ca0efa9f5633cb0371bbc0355478d8+13 0:13:hello\\040world.txt
250 """
251         self.assertEqual(arvados.CollectionReader(m8).manifest_text(), m8)
252
253 class LocatorsAndRangesTest(unittest.TestCase):
254     def runTest(self):
255         blocks2 = [['a', 10, 0],
256                   ['b', 10, 10],
257                   ['c', 10, 20],
258                   ['d', 10, 30],
259                   ['e', 10, 40],
260                   ['f', 10, 50]]
261
262         self.assertEqual(arvados.locators_and_ranges(blocks2,  2,  2), [['a', 10, 2, 2]])
263         self.assertEqual(arvados.locators_and_ranges(blocks2, 12, 2), [['b', 10, 2, 2]])
264         self.assertEqual(arvados.locators_and_ranges(blocks2, 22, 2), [['c', 10, 2, 2]])
265         self.assertEqual(arvados.locators_and_ranges(blocks2, 32, 2), [['d', 10, 2, 2]])
266         self.assertEqual(arvados.locators_and_ranges(blocks2, 42, 2), [['e', 10, 2, 2]])
267         self.assertEqual(arvados.locators_and_ranges(blocks2, 52, 2), [['f', 10, 2, 2]])
268         self.assertEqual(arvados.locators_and_ranges(blocks2, 62, 2), [])
269         self.assertEqual(arvados.locators_and_ranges(blocks2, -2, 2), [])
270
271         self.assertEqual(arvados.locators_and_ranges(blocks2,  0,  2), [['a', 10, 0, 2]])
272         self.assertEqual(arvados.locators_and_ranges(blocks2, 10, 2), [['b', 10, 0, 2]])
273         self.assertEqual(arvados.locators_and_ranges(blocks2, 20, 2), [['c', 10, 0, 2]])
274         self.assertEqual(arvados.locators_and_ranges(blocks2, 30, 2), [['d', 10, 0, 2]])
275         self.assertEqual(arvados.locators_and_ranges(blocks2, 40, 2), [['e', 10, 0, 2]])
276         self.assertEqual(arvados.locators_and_ranges(blocks2, 50, 2), [['f', 10, 0, 2]])
277         self.assertEqual(arvados.locators_and_ranges(blocks2, 60, 2), [])
278         self.assertEqual(arvados.locators_and_ranges(blocks2, -2, 2), [])
279
280         self.assertEqual(arvados.locators_and_ranges(blocks2,  9,  2), [['a', 10, 9, 1], ['b', 10, 0, 1]])
281         self.assertEqual(arvados.locators_and_ranges(blocks2, 19, 2), [['b', 10, 9, 1], ['c', 10, 0, 1]])
282         self.assertEqual(arvados.locators_and_ranges(blocks2, 29, 2), [['c', 10, 9, 1], ['d', 10, 0, 1]])
283         self.assertEqual(arvados.locators_and_ranges(blocks2, 39, 2), [['d', 10, 9, 1], ['e', 10, 0, 1]])
284         self.assertEqual(arvados.locators_and_ranges(blocks2, 49, 2), [['e', 10, 9, 1], ['f', 10, 0, 1]])
285         self.assertEqual(arvados.locators_and_ranges(blocks2, 59, 2), [['f', 10, 9, 1]])
286
287         
288         blocks3 = [['a', 10, 0],
289                   ['b', 10, 10],
290                   ['c', 10, 20],
291                   ['d', 10, 30],
292                   ['e', 10, 40],
293                   ['f', 10, 50],
294                   ['g', 10, 60]]
295
296         self.assertEqual(arvados.locators_and_ranges(blocks3,  2,  2), [['a', 10, 2, 2]])
297         self.assertEqual(arvados.locators_and_ranges(blocks3, 12, 2), [['b', 10, 2, 2]])
298         self.assertEqual(arvados.locators_and_ranges(blocks3, 22, 2), [['c', 10, 2, 2]])
299         self.assertEqual(arvados.locators_and_ranges(blocks3, 32, 2), [['d', 10, 2, 2]])
300         self.assertEqual(arvados.locators_and_ranges(blocks3, 42, 2), [['e', 10, 2, 2]])
301         self.assertEqual(arvados.locators_and_ranges(blocks3, 52, 2), [['f', 10, 2, 2]])
302         self.assertEqual(arvados.locators_and_ranges(blocks3, 62, 2), [['g', 10, 2, 2]])
303
304
305         blocks = [['a', 10, 0],
306                   ['b', 15, 10],
307                   ['c', 5, 25]]
308         self.assertEqual(arvados.locators_and_ranges(blocks, 1, 0), [])
309         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 5), [['a', 10, 0, 5]])
310         self.assertEqual(arvados.locators_and_ranges(blocks, 3, 5), [['a', 10, 3, 5]])
311         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 10), [['a', 10, 0, 10]])
312         
313         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 11), [['a', 10, 0, 10],
314                                                                       ['b', 15, 0, 1]])
315         self.assertEqual(arvados.locators_and_ranges(blocks, 1, 11), [['a', 10, 1, 9],
316                                                                       ['b', 15, 0, 2]])
317         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 25), [['a', 10, 0, 10],
318                                                                       ['b', 15, 0, 15]])
319         
320         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 30), [['a', 10, 0, 10],
321                                                                       ['b', 15, 0, 15],
322                                                                       ['c', 5, 0, 5]])
323         self.assertEqual(arvados.locators_and_ranges(blocks, 1, 30), [['a', 10, 1, 9],
324                                                                       ['b', 15, 0, 15],
325                                                                       ['c', 5, 0, 5]])
326         self.assertEqual(arvados.locators_and_ranges(blocks, 0, 31), [['a', 10, 0, 10],
327                                                                       ['b', 15, 0, 15],
328                                                                       ['c', 5, 0, 5]])
329         
330         self.assertEqual(arvados.locators_and_ranges(blocks, 15, 5), [['b', 15, 5, 5]])
331         
332         self.assertEqual(arvados.locators_and_ranges(blocks, 8, 17), [['a', 10, 8, 2],
333                                                                       ['b', 15, 0, 15]])
334
335         self.assertEqual(arvados.locators_and_ranges(blocks, 8, 20), [['a', 10, 8, 2],
336                                                                       ['b', 15, 0, 15],
337                                                                       ['c', 5, 0, 3]])
338         
339         self.assertEqual(arvados.locators_and_ranges(blocks, 26, 2), [['c', 5, 1, 2]])
340         
341         self.assertEqual(arvados.locators_and_ranges(blocks, 9, 15), [['a', 10, 9, 1],
342                                                                       ['b', 15, 0, 14]])        
343         self.assertEqual(arvados.locators_and_ranges(blocks, 10, 15), [['b', 15, 0, 15]])
344         self.assertEqual(arvados.locators_and_ranges(blocks, 11, 15), [['b', 15, 1, 14],
345                                                                        ['c', 5, 0, 1]])
346
347 class FileStreamTest(unittest.TestCase):
348     class MockStreamReader(object):
349         def __init__(self, content):
350             self.content = content
351
352         def readfrom(self, start, size):
353             return self.content[start:start+size]
354
355     def runTest(self):
356         content = 'abcdefghijklmnopqrstuvwxyz0123456789'
357         msr = FileStreamTest.MockStreamReader(content)
358         segments = [[0, 10, 0],
359                     [10, 15, 10],
360                     [25, 5, 25]]
361         
362         sfr = arvados.StreamFileReader(msr, segments, "test")
363
364         self.assertEqual(sfr.name(), "test")
365         self.assertEqual(sfr.size(), 30)
366
367         self.assertEqual(sfr.readfrom(0, 30), content[0:30])
368         self.assertEqual(sfr.readfrom(2, 30), content[2:30])
369
370         self.assertEqual(sfr.readfrom(2, 8), content[2:10])
371         self.assertEqual(sfr.readfrom(0, 10), content[0:10])
372
373         self.assertEqual(sfr.tell(), 0)
374         self.assertEqual(sfr.read(5), content[0:5])
375         self.assertEqual(sfr.tell(), 5)
376         self.assertEqual(sfr.read(5), content[5:10])
377         self.assertEqual(sfr.tell(), 10)
378         self.assertEqual(sfr.read(5), content[10:15])
379         self.assertEqual(sfr.tell(), 15)
380         self.assertEqual(sfr.read(5), content[15:20])
381         self.assertEqual(sfr.tell(), 20)
382         self.assertEqual(sfr.read(5), content[20:25])
383         self.assertEqual(sfr.tell(), 25)
384         self.assertEqual(sfr.read(5), content[25:30])
385         self.assertEqual(sfr.tell(), 30)
386         self.assertEqual(sfr.read(5), '')
387         self.assertEqual(sfr.tell(), 30)
388
389         segments = [[26, 10, 0],
390                     [0, 15, 10],
391                     [15, 5, 25]]
392         
393         sfr = arvados.StreamFileReader(msr, segments, "test")
394
395         self.assertEqual(sfr.size(), 30)
396
397         self.assertEqual(sfr.readfrom(0, 30), content[26:36] + content[0:20])
398         self.assertEqual(sfr.readfrom(2, 30), content[28:36] + content[0:20])
399
400         self.assertEqual(sfr.readfrom(2, 8), content[28:36])
401         self.assertEqual(sfr.readfrom(0, 10), content[26:36])
402
403         self.assertEqual(sfr.tell(), 0)
404         self.assertEqual(sfr.read(5), content[26:31])
405         self.assertEqual(sfr.tell(), 5)
406         self.assertEqual(sfr.read(5), content[31:36])
407         self.assertEqual(sfr.tell(), 10)
408         self.assertEqual(sfr.read(5), content[0:5])
409         self.assertEqual(sfr.tell(), 15)
410         self.assertEqual(sfr.read(5), content[5:10])
411         self.assertEqual(sfr.tell(), 20)
412         self.assertEqual(sfr.read(5), content[10:15])
413         self.assertEqual(sfr.tell(), 25)
414         self.assertEqual(sfr.read(5), content[15:20])
415         self.assertEqual(sfr.tell(), 30)
416         self.assertEqual(sfr.read(5), '')
417         self.assertEqual(sfr.tell(), 30)
418
419
420 class StreamReaderTest(unittest.TestCase):
421
422     class MockKeep(object):
423         def __init__(self, content):
424             self.content = content
425
426         def get(self, locator):
427             return self.content[locator]
428
429     def runTest(self):
430         keepblocks = {'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+10': 'abcdefghij', 
431                       'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+15': 'klmnopqrstuvwxy', 
432                       'cccccccccccccccccccccccccccccccc+5': 'z0123'}
433         mk = StreamReaderTest.MockKeep(keepblocks)
434
435         sr = arvados.StreamReader([".", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+10", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+15", "cccccccccccccccccccccccccccccccc+5", "0:30:foo"], mk)
436
437         content = 'abcdefghijklmnopqrstuvwxyz0123456789'
438
439         self.assertEqual(sr.readfrom(0, 30), content[0:30])
440         self.assertEqual(sr.readfrom(2, 30), content[2:30])
441
442         self.assertEqual(sr.readfrom(2, 8), content[2:10])
443         self.assertEqual(sr.readfrom(0, 10), content[0:10])
444
445         self.assertEqual(sr.readfrom(0, 5), content[0:5])
446         self.assertEqual(sr.readfrom(5, 5), content[5:10])
447         self.assertEqual(sr.readfrom(10, 5), content[10:15])
448         self.assertEqual(sr.readfrom(15, 5), content[15:20])
449         self.assertEqual(sr.readfrom(20, 5), content[20:25])
450         self.assertEqual(sr.readfrom(25, 5), content[25:30])
451         self.assertEqual(sr.readfrom(30, 5), '')
452
453 class ExtractFileTest(unittest.TestCase):
454     def runTest(self):
455         m1 = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
456 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md6sum.txt
457 . 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md7sum.txt
458 . 085c37f02916da1cad16f93c54d899b7+41 5348b82a029fd9e971a811ce1f71360b+43 8b22da26f9f433dea0a10e5ec66d73ba+43 47:80:md8sum.txt
459 . 085c37f02916da1cad16f93c54d899b7+41 5348b82a029fd9e971a811ce1f71360b+43 8b22da26f9f433dea0a10e5ec66d73ba+43 40:80:md9sum.txt"""
460
461         m2 = arvados.CollectionReader(m1)
462
463         self.assertEqual(m2.manifest_text(),
464                          ". 5348b82a029fd9e971a811ce1f71360b+43 085c37f02916da1cad16f93c54d899b7+41 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md5sum.txt 43:41:md6sum.txt 84:43:md7sum.txt 6:37:md8sum.txt 84:43:md8sum.txt 83:1:md9sum.txt 0:43:md9sum.txt 84:36:md9sum.txt\n")
465
466         self.assertEqual(arvados.CollectionReader(m1).all_streams()[0].files()['md5sum.txt'].as_manifest(),
467                          ". 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt\n")
468         self.assertEqual(arvados.CollectionReader(m1).all_streams()[0].files()['md6sum.txt'].as_manifest(),
469                          ". 085c37f02916da1cad16f93c54d899b7+41 0:41:md6sum.txt\n")
470         self.assertEqual(arvados.CollectionReader(m1).all_streams()[0].files()['md7sum.txt'].as_manifest(),
471                          ". 8b22da26f9f433dea0a10e5ec66d73ba+43 0:43:md7sum.txt\n")
472         self.assertEqual(arvados.CollectionReader(m1).all_streams()[0].files()['md9sum.txt'].as_manifest(),
473                          ". 085c37f02916da1cad16f93c54d899b7+41 5348b82a029fd9e971a811ce1f71360b+43 8b22da26f9f433dea0a10e5ec66d73ba+43 40:80:md9sum.txt\n")