def test_extract_archive(self): mapping = [ ({'xy.zip', 'xy.7z', 'xy.rar', 'xy.tar'}, {'x.csv', 'y.csv', 'z.json'}), ({'x.csv.xz', 'x.csv.gz', 'x.csv.bz2'}, {'x.csv'}), ({'xy.tar.xz', 'xy.tar.gz', 'xy.tar.bz2'}, {'xy.tar'}), ] for archives, files in mapping: for archive in archives: target = meta.filename(archive, self.root) meta.extract_archive(archive, target, meta.guess_format(archive)) eq_(set(os.listdir(target)), files)
def test_filename(self): eq_(meta.filename('http://a.co/file.ext?q=1&y=2#z=3', root='/path'), os.path.abspath('/path/56f90b4e3b-file.ext')) eq_(meta.filename('http://a.co/?q=1&y=2#z=3', root='/path', path='file.ext'), os.path.abspath('/path/d8f477152f-file.ext'))