def test_mapping_complex_multiple(self):
        demo3 = path('demo3.zip')
        demo4 = path('demo4.zip')
        m = DefaultMapper()
        # load order matters, new entries will not overwrite old ones.
        m.load_archive(demo3)
        m.load_archive(demo4)

        self.assertDemo3ThenDemo4(m, demo3, demo4)

        self.assertEqual(
            m.traverse('demo/dir1/file1'), (demo3, 'demo/dir1/file1', 33))
        self.assertEqual(
            m.readfile('demo/dir1/file1'),
            b'b026324c6904b2a9cb4b88d6d61c81d1\n')

        self.assertEqual(
            m.traverse('demo/dir1/file5'), (demo4, 'demo/dir1/file5', 26))
        self.assertEqual(
            m.traverse('demo/dir4/dir5/dir6/file6'),
            (demo3, 'demo/dir4/dir5/dir6/file6', 33))

        self.assertEqual(
            m.readfile('demo/dir1/file5'),
            b'demo4.zip demo/dir1/file5\n')

        self.assertEqual(sorted(m.readdir('')), ['demo', 'hello'])
Example #2
0
    def test_mapping_complex_multiple(self):
        demo3 = path('demo3.zip')
        demo4 = path('demo4.zip')
        m = DefaultMapper()
        # load order matters, new entries will not overwrite old ones.
        m.load_archive(demo3)
        m.load_archive(demo4)

        self.assertDemo3ThenDemo4(m, demo3, demo4)

        self.assertEqual(m.traverse('demo/dir1/file1'),
                         (demo3, 'demo/dir1/file1', 33))
        self.assertEqual(m.readfile('demo/dir1/file1'),
                         b'b026324c6904b2a9cb4b88d6d61c81d1\n')

        self.assertEqual(m.traverse('demo/dir1/file5'),
                         (demo4, 'demo/dir1/file5', 26))
        self.assertEqual(m.traverse('demo/dir4/dir5/dir6/file6'),
                         (demo3, 'demo/dir4/dir5/dir6/file6', 33))

        self.assertEqual(m.readfile('demo/dir1/file5'),
                         b'demo4.zip demo/dir1/file5\n')

        self.assertEqual(sorted(m.readdir('')), ['demo', 'hello'])
    def test_mapping_simple(self):
        target = path('demo1.zip')
        m = DefaultMapper(target)
        self.assertEqual(m.mapping, {
            'file1': (target, 'file1', 33),
            'file2': (target, 'file2', 33),
            'file3': (target, 'file3', 33),
            'file4': (target, 'file4', 33),
            'file5': (target, 'file5', 33),
            'file6': (target, 'file6', 33),
        })

        self.assertEqual(m.traverse('file1'), (target, 'file1', 33))
        self.assertEqual(
            m.readfile('file1'), b'b026324c6904b2a9cb4b88d6d61c81d1\n')
Example #4
0
    def test_mapping_simple(self):
        target = path('demo1.zip')
        m = DefaultMapper(target)
        self.assertEqual(
            m.mapping, {
                'file1': (target, 'file1', 33),
                'file2': (target, 'file2', 33),
                'file3': (target, 'file3', 33),
                'file4': (target, 'file4', 33),
                'file5': (target, 'file5', 33),
                'file6': (target, 'file6', 33),
            })

        self.assertEqual(m.traverse('file1'), (target, 'file1', 33))
        self.assertEqual(m.readfile('file1'),
                         b'b026324c6904b2a9cb4b88d6d61c81d1\n')