def test_unload_infolist_dir_file_conflict(self): m = DefaultMapper() m._load_infolist('/tmp/demo1.zip', [zipinfo('demo/')]) m._load_infolist('/tmp/demo2.zip', [zipinfo('demo')]) self.assertEqual(m.mapping, {'demo': {}}) m._unload_infolist('/tmp/demo2.zip') self.assertEqual(m.mapping, {'demo': {}})
def test_unload_infolist_dir_unloading(self): m = DefaultMapper() m._load_infolist('/tmp/demo1.zip', [zipinfo('demo/demo/1.txt', 1)]) m._load_infolist('/tmp/demo2.zip', [zipinfo('demo/')]) m._load_infolist('/tmp/demo3.zip', [zipinfo('demo')]) m._load_infolist('/tmp/demo4.zip', [zipinfo('demo/demo4.txt', 1)]) self.assertEqual( m.mapping, { 'demo': { 'demo': { '1.txt': ('/tmp/demo1.zip', 'demo/demo/1.txt', 1) }, 'demo4.txt': ('/tmp/demo4.zip', 'demo/demo4.txt', 1), } }) m._unload_infolist('/tmp/demo1.zip') self.assertEqual( m.mapping, {'demo': { 'demo4.txt': ('/tmp/demo4.zip', 'demo/demo4.txt', 1), }}) m._load_infolist('/tmp/demo1.zip', [zipinfo('demo/demo/1.txt', 1)]) m._unload_infolist('/tmp/demo4.zip') self.assertEqual( m.mapping, { 'demo': { 'demo': { '1.txt': ('/tmp/demo1.zip', 'demo/demo/1.txt', 1) }, } })
def test_unload_infolist_file_dir_conflict(self): m = DefaultMapper() m._load_infolist('/tmp/demo1.zip', [zipinfo('demo')]) m._load_infolist('/tmp/demo2.zip', [zipinfo('demo/')]) self.assertEqual(m.mapping, {'demo': ('/tmp/demo1.zip', 'demo', 0)}) m._unload_infolist('/tmp/demo1.zip') # directory not created. self.assertEqual(m.mapping, {})
def test_load_infolist_alternative_pathmaking(self): demo1 = path('demo1.zip') demo2 = path('demo2.zip') m = DefaultMapper(pathmaker_name='flatten', include_arcname=True) with ZipFile(demo1) as zf: # loading as demo_demo to conflict with below m._load_infolist('/tmp/demo_demo', zf.infolist()) with ZipFile(demo2) as zf: m._load_infolist('/tmp/demo', zf.infolist()) self.assertEqual({k: list(v) for k, v in m.reverse_mapping.items()}, { '': [('/tmp/demo', 'demo/', 0)], 'demo_demo_file1': [('/tmp/demo_demo', 'file1', 33), ('/tmp/demo', 'demo/file1', 33)], 'demo_demo_file2': [('/tmp/demo_demo', 'file2', 33), ('/tmp/demo', 'demo/file2', 33)], 'demo_demo_file3': [('/tmp/demo_demo', 'file3', 33), ('/tmp/demo', 'demo/file3', 33)], 'demo_demo_file4': [('/tmp/demo_demo', 'file4', 33), ('/tmp/demo', 'demo/file4', 33)], 'demo_demo_file5': [('/tmp/demo_demo', 'file5', 33), ('/tmp/demo', 'demo/file5', 33)], 'demo_demo_file6': [('/tmp/demo_demo', 'file6', 33), ('/tmp/demo', 'demo/file6', 33)], }) self.assertEqual(m.mapping, { 'demo_demo_file1': ('/tmp/demo_demo', 'file1', 33), 'demo_demo_file2': ('/tmp/demo_demo', 'file2', 33), 'demo_demo_file3': ('/tmp/demo_demo', 'file3', 33), 'demo_demo_file4': ('/tmp/demo_demo', 'file4', 33), 'demo_demo_file5': ('/tmp/demo_demo', 'file5', 33), 'demo_demo_file6': ('/tmp/demo_demo', 'file6', 33), }) m._unload_infolist('/tmp/demo_demo') self.assertEqual({k: list(v) for k, v in m.reverse_mapping.items()}, { '': [('/tmp/demo', 'demo/', 0)], 'demo_demo_file1': [('/tmp/demo', 'demo/file1', 33)], 'demo_demo_file2': [('/tmp/demo', 'demo/file2', 33)], 'demo_demo_file3': [('/tmp/demo', 'demo/file3', 33)], 'demo_demo_file4': [('/tmp/demo', 'demo/file4', 33)], 'demo_demo_file5': [('/tmp/demo', 'demo/file5', 33)], 'demo_demo_file6': [('/tmp/demo', 'demo/file6', 33)], }) self.assertEqual(m.mapping, { 'demo_demo_file1': ('/tmp/demo', 'demo/file1', 33), 'demo_demo_file2': ('/tmp/demo', 'demo/file2', 33), 'demo_demo_file3': ('/tmp/demo', 'demo/file3', 33), 'demo_demo_file4': ('/tmp/demo', 'demo/file4', 33), 'demo_demo_file5': ('/tmp/demo', 'demo/file5', 33), 'demo_demo_file6': ('/tmp/demo', 'demo/file6', 33), })
def test_unload_infolist_simple(self): demo1 = path('demo1.zip') m = DefaultMapper() with ZipFile(demo1) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._unload_infolist('/tmp/demo1.zip') self.assertEqual(m.mapping, {}) self.assertEqual(m.reverse_mapping, {}) self.assertEqual(m.archives, {}) self.assertEqual(m.archive_ifilenames, {})
def test_unload_infolist_file_dir_dir_conflict(self): m = DefaultMapper() m._load_infolist('/tmp/demo1.zip', [zipinfo('demo')]) m._load_infolist('/tmp/demo2.zip', [zipinfo('demo/')]) m._load_infolist('/tmp/demo3.zip', [zipinfo('demo/demo.txt', 1)]) self.assertEqual(m.mapping, {'demo': ('/tmp/demo1.zip', 'demo', 0)}) m._unload_infolist('/tmp/demo1.zip') # directory not created. Alternative implementation could have # added the same entry to a shadow location so it would show up # here, hide it again when inactive. self.assertEqual(m.mapping, {}) m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping, {})
def test_unload_infolist_multiple_reload(self): demo = path('demo2.zip') m = DefaultMapper() with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) m._unload_infolist('/tmp/demo1.zip') d2list = { 'file1': ('/tmp/demo2.zip', 'demo/file1', 33), 'file2': ('/tmp/demo2.zip', 'demo/file2', 33), 'file3': ('/tmp/demo2.zip', 'demo/file3', 33), 'file4': ('/tmp/demo2.zip', 'demo/file4', 33), 'file5': ('/tmp/demo2.zip', 'demo/file5', 33), 'file6': ('/tmp/demo2.zip', 'demo/file6', 33), } self.assertEqual(m.mapping, {'demo': d2list}) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo4.zip', zf.infolist()) # Shouldn't overwrite now. self.assertEqual(m.mapping['demo'], d2list) m._unload_infolist('/tmp/demo2.zip') # Shouldn't be affected because they don't belong to demo2. self.assertEqual( m.mapping['demo'], {k: ('/tmp/demo3.zip', v[1], v[2]) for k, v in d2list.items()}) # latest one is unloaded. self.assertEqual(list(v[0] for v in m.reverse_mapping['demo/']), ['/tmp/demo3.zip', '/tmp/demo4.zip']) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo3.zip', '/tmp/demo4.zip']) self.assertEqual(sorted(m.archive_ifilenames['/tmp/demo3.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) m._unload_infolist('/tmp/demo4.zip') self.assertEqual( m.mapping['demo'], {k: ('/tmp/demo3.zip', v[1], v[2]) for k, v in d2list.items()}) # everything still removed, at last. m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping, {})
def test_unload_infolist_multiple_reload(self): demo = path('demo2.zip') m = DefaultMapper() with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) m._unload_infolist('/tmp/demo1.zip') d2list = { 'file1': ('/tmp/demo2.zip', 'demo/file1', 33), 'file2': ('/tmp/demo2.zip', 'demo/file2', 33), 'file3': ('/tmp/demo2.zip', 'demo/file3', 33), 'file4': ('/tmp/demo2.zip', 'demo/file4', 33), 'file5': ('/tmp/demo2.zip', 'demo/file5', 33), 'file6': ('/tmp/demo2.zip', 'demo/file6', 33), } self.assertEqual(m.mapping, {'demo': d2list}) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo4.zip', zf.infolist()) # Shouldn't overwrite now. self.assertEqual(m.mapping['demo'], d2list) m._unload_infolist('/tmp/demo2.zip') # Shouldn't be affected because they don't belong to demo2. self.assertEqual(m.mapping['demo'], { k: ('/tmp/demo3.zip', v[1], v[2]) for k, v in d2list.items() }) # latest one is unloaded. self.assertEqual(list(v[0] for v in m.reverse_mapping['demo/']), ['/tmp/demo3.zip', '/tmp/demo4.zip']) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo3.zip', '/tmp/demo4.zip']) self.assertEqual( sorted(m.archive_ifilenames['/tmp/demo3.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) m._unload_infolist('/tmp/demo4.zip') self.assertEqual(m.mapping['demo'], { k: ('/tmp/demo3.zip', v[1], v[2]) for k, v in d2list.items() }) # everything still removed, at last. m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping, {})
def test_unload_infolist_dir_unloading(self): m = DefaultMapper() m._load_infolist('/tmp/demo1.zip', [zipinfo('demo/demo/1.txt', 1)]) m._load_infolist('/tmp/demo2.zip', [zipinfo('demo/')]) m._load_infolist('/tmp/demo3.zip', [zipinfo('demo')]) m._load_infolist('/tmp/demo4.zip', [zipinfo('demo/demo4.txt', 1)]) self.assertEqual(m.mapping, {'demo': { 'demo': {'1.txt': ('/tmp/demo1.zip', 'demo/demo/1.txt', 1)}, 'demo4.txt': ('/tmp/demo4.zip', 'demo/demo4.txt', 1), }}) m._unload_infolist('/tmp/demo1.zip') self.assertEqual(m.mapping, {'demo': { 'demo4.txt': ('/tmp/demo4.zip', 'demo/demo4.txt', 1), }}) m._load_infolist('/tmp/demo1.zip', [zipinfo('demo/demo/1.txt', 1)]) m._unload_infolist('/tmp/demo4.zip') self.assertEqual(m.mapping, {'demo': { 'demo': {'1.txt': ('/tmp/demo1.zip', 'demo/demo/1.txt', 1)}, }})
def test_load_infolist_alternative_pathmaking(self): demo1 = path('demo1.zip') demo2 = path('demo2.zip') m = DefaultMapper(pathmaker_name='flatten', include_arcname=True) with ZipFile(demo1) as zf: # loading as demo_demo to conflict with below m._load_infolist('/tmp/demo_demo', zf.infolist()) with ZipFile(demo2) as zf: m._load_infolist('/tmp/demo', zf.infolist()) self.assertEqual( {k: list(v) for k, v in m.reverse_mapping.items()}, { '': [('/tmp/demo', 'demo/', 0)], 'demo_demo_file1': [('/tmp/demo_demo', 'file1', 33), ('/tmp/demo', 'demo/file1', 33)], 'demo_demo_file2': [('/tmp/demo_demo', 'file2', 33), ('/tmp/demo', 'demo/file2', 33)], 'demo_demo_file3': [('/tmp/demo_demo', 'file3', 33), ('/tmp/demo', 'demo/file3', 33)], 'demo_demo_file4': [('/tmp/demo_demo', 'file4', 33), ('/tmp/demo', 'demo/file4', 33)], 'demo_demo_file5': [('/tmp/demo_demo', 'file5', 33), ('/tmp/demo', 'demo/file5', 33)], 'demo_demo_file6': [('/tmp/demo_demo', 'file6', 33), ('/tmp/demo', 'demo/file6', 33)], }) self.assertEqual( m.mapping, { 'demo_demo_file1': ('/tmp/demo_demo', 'file1', 33), 'demo_demo_file2': ('/tmp/demo_demo', 'file2', 33), 'demo_demo_file3': ('/tmp/demo_demo', 'file3', 33), 'demo_demo_file4': ('/tmp/demo_demo', 'file4', 33), 'demo_demo_file5': ('/tmp/demo_demo', 'file5', 33), 'demo_demo_file6': ('/tmp/demo_demo', 'file6', 33), }) m._unload_infolist('/tmp/demo_demo') self.assertEqual( {k: list(v) for k, v in m.reverse_mapping.items()}, { '': [('/tmp/demo', 'demo/', 0)], 'demo_demo_file1': [('/tmp/demo', 'demo/file1', 33)], 'demo_demo_file2': [('/tmp/demo', 'demo/file2', 33)], 'demo_demo_file3': [('/tmp/demo', 'demo/file3', 33)], 'demo_demo_file4': [('/tmp/demo', 'demo/file4', 33)], 'demo_demo_file5': [('/tmp/demo', 'demo/file5', 33)], 'demo_demo_file6': [('/tmp/demo', 'demo/file6', 33)], }) self.assertEqual( m.mapping, { 'demo_demo_file1': ('/tmp/demo', 'demo/file1', 33), 'demo_demo_file2': ('/tmp/demo', 'demo/file2', 33), 'demo_demo_file3': ('/tmp/demo', 'demo/file3', 33), 'demo_demo_file4': ('/tmp/demo', 'demo/file4', 33), 'demo_demo_file5': ('/tmp/demo', 'demo/file5', 33), 'demo_demo_file6': ('/tmp/demo', 'demo/file6', 33), })
def test_unload_infolist_multiple(self): demo = path('demo2.zip') m = DefaultMapper() # XXX should just store the zf.infolist() somewhere. with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo3.zip'] ) # lazy way to check old_reverse_mapping = str(m.reverse_mapping) m._unload_infolist('/tmp/demo2.zip') # Not the oldest entry self.assertEqual(m.mapping['demo'], { 'file1': ('/tmp/demo1.zip', 'demo/file1', 33), 'file2': ('/tmp/demo1.zip', 'demo/file2', 33), 'file3': ('/tmp/demo1.zip', 'demo/file3', 33), 'file4': ('/tmp/demo1.zip', 'demo/file4', 33), 'file5': ('/tmp/demo1.zip', 'demo/file5', 33), 'file6': ('/tmp/demo1.zip', 'demo/file6', 33), }) self.assertEqual(str(m.reverse_mapping), old_reverse_mapping) self.assertEqual(len(m.archives), 2) self.assertNotIn('/tmp/demo2.zip', m.archives) self.assertEqual( list(m.archive_ifilenames.keys()), list(m.archives.keys())) with self.assertRaises(KeyError): m._unload_infolist('/tmp/demo2.zip') m._unload_infolist('/tmp/demo1.zip') self.assertEqual(m.mapping, {'demo': { 'file1': ('/tmp/demo3.zip', 'demo/file1', 33), 'file2': ('/tmp/demo3.zip', 'demo/file2', 33), 'file3': ('/tmp/demo3.zip', 'demo/file3', 33), 'file4': ('/tmp/demo3.zip', 'demo/file4', 33), 'file5': ('/tmp/demo3.zip', 'demo/file5', 33), 'file6': ('/tmp/demo3.zip', 'demo/file6', 33), }}) self.assertEqual( list(m.reverse_mapping['demo/']), [('/tmp/demo3.zip', 'demo/', 0)], ) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo3.zip']) self.assertEqual( sorted(m.archive_ifilenames['/tmp/demo3.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) # finally, unload the final one. m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping, {}) self.assertEqual(m.reverse_mapping, {}) self.assertEqual(m.archives, {}) self.assertEqual(m.archive_ifilenames, {})
def test_unload_infolist_multiple_overwrite(self): demo = path('demo2.zip') m = DefaultMapper(overwrite=True) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) d3list = { 'file1': ('/tmp/demo3.zip', 'demo/file1', 33), 'file2': ('/tmp/demo3.zip', 'demo/file2', 33), 'file3': ('/tmp/demo3.zip', 'demo/file3', 33), 'file4': ('/tmp/demo3.zip', 'demo/file4', 33), 'file5': ('/tmp/demo3.zip', 'demo/file5', 33), 'file6': ('/tmp/demo3.zip', 'demo/file6', 33), } self.assertEqual(m.mapping, {'demo': d3list}) # Unloading the latest one. m._unload_infolist('/tmp/demo3.zip') self.assertEqual( m.mapping['demo'], {k: ('/tmp/demo2.zip', v[1], v[2]) for k, v in d3list.items()}) self.assertEqual(list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip']) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo1.zip', '/tmp/demo2.zip']) self.assertEqual(sorted(m.archive_ifilenames['/tmp/demo1.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo4.zip', zf.infolist()) m._unload_infolist('/tmp/demo1.zip') self.assertEqual( m.mapping['demo'], {k: ('/tmp/demo4.zip', v[1], v[2]) for k, v in d3list.items()}) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo4.zip']) m._unload_infolist('/tmp/demo2.zip') self.assertEqual( m.mapping['demo'], {k: ('/tmp/demo4.zip', v[1], v[2]) for k, v in d3list.items()}) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo4.zip']) # Finally everything that can be cleaned, cleaned. m._unload_infolist('/tmp/demo4.zip') self.assertEqual(m.mapping, {}) self.assertEqual(m.reverse_mapping, {}) self.assertEqual(m.archives, {}) self.assertEqual(m.archive_ifilenames, {})
def test_unload_infolist_multiple(self): demo = path('demo2.zip') m = DefaultMapper() # XXX should just store the zf.infolist() somewhere. with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo3.zip']) # lazy way to check old_reverse_mapping = str(m.reverse_mapping) m._unload_infolist('/tmp/demo2.zip') # Not the oldest entry self.assertEqual( m.mapping['demo'], { 'file1': ('/tmp/demo1.zip', 'demo/file1', 33), 'file2': ('/tmp/demo1.zip', 'demo/file2', 33), 'file3': ('/tmp/demo1.zip', 'demo/file3', 33), 'file4': ('/tmp/demo1.zip', 'demo/file4', 33), 'file5': ('/tmp/demo1.zip', 'demo/file5', 33), 'file6': ('/tmp/demo1.zip', 'demo/file6', 33), }) self.assertEqual(str(m.reverse_mapping), old_reverse_mapping) self.assertEqual(len(m.archives), 2) self.assertNotIn('/tmp/demo2.zip', m.archives) self.assertEqual(list(m.archive_ifilenames.keys()), list(m.archives.keys())) with self.assertRaises(KeyError): m._unload_infolist('/tmp/demo2.zip') m._unload_infolist('/tmp/demo1.zip') self.assertEqual( m.mapping, { 'demo': { 'file1': ('/tmp/demo3.zip', 'demo/file1', 33), 'file2': ('/tmp/demo3.zip', 'demo/file2', 33), 'file3': ('/tmp/demo3.zip', 'demo/file3', 33), 'file4': ('/tmp/demo3.zip', 'demo/file4', 33), 'file5': ('/tmp/demo3.zip', 'demo/file5', 33), 'file6': ('/tmp/demo3.zip', 'demo/file6', 33), } }) self.assertEqual( list(m.reverse_mapping['demo/']), [('/tmp/demo3.zip', 'demo/', 0)], ) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo3.zip']) self.assertEqual(sorted(m.archive_ifilenames['/tmp/demo3.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) # finally, unload the final one. m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping, {}) self.assertEqual(m.reverse_mapping, {}) self.assertEqual(m.archives, {}) self.assertEqual(m.archive_ifilenames, {})
def test_unload_infolist_multiple_overwrite(self): demo = path('demo2.zip') m = DefaultMapper(overwrite=True) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo1.zip', zf.infolist()) m._load_infolist('/tmp/demo2.zip', zf.infolist()) m._load_infolist('/tmp/demo3.zip', zf.infolist()) d3list = { 'file1': ('/tmp/demo3.zip', 'demo/file1', 33), 'file2': ('/tmp/demo3.zip', 'demo/file2', 33), 'file3': ('/tmp/demo3.zip', 'demo/file3', 33), 'file4': ('/tmp/demo3.zip', 'demo/file4', 33), 'file5': ('/tmp/demo3.zip', 'demo/file5', 33), 'file6': ('/tmp/demo3.zip', 'demo/file6', 33), } self.assertEqual(m.mapping, {'demo': d3list}) # Unloading the latest one. m._unload_infolist('/tmp/demo3.zip') self.assertEqual(m.mapping['demo'], { k: ('/tmp/demo2.zip', v[1], v[2]) for k, v in d3list.items() }) self.assertEqual(list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip']) self.assertEqual(sorted(m.archives.keys()), ['/tmp/demo1.zip', '/tmp/demo2.zip']) self.assertEqual( sorted(m.archive_ifilenames['/tmp/demo1.zip']), [ 'demo/', 'demo/file1', 'demo/file2', 'demo/file3', 'demo/file4', 'demo/file5', 'demo/file6' ]) with ZipFile(demo) as zf: m._load_infolist('/tmp/demo4.zip', zf.infolist()) m._unload_infolist('/tmp/demo1.zip') self.assertEqual(m.mapping['demo'], { k: ('/tmp/demo4.zip', v[1], v[2]) for k, v in d3list.items() }) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo4.zip'] ) m._unload_infolist('/tmp/demo2.zip') self.assertEqual(m.mapping['demo'], { k: ('/tmp/demo4.zip', v[1], v[2]) for k, v in d3list.items() }) self.assertEqual( list(f[0] for f in m.reverse_mapping['demo/']), ['/tmp/demo1.zip', '/tmp/demo2.zip', '/tmp/demo4.zip'] ) # Finally everything that can be cleaned, cleaned. m._unload_infolist('/tmp/demo4.zip') self.assertEqual(m.mapping, {}) self.assertEqual(m.reverse_mapping, {}) self.assertEqual(m.archives, {}) self.assertEqual(m.archive_ifilenames, {})