Exemple #1
0
    def test_copy_structure(self):
        mem_fs = open_fs('mem://')
        self.fs.makedirs('foo/bar/baz')
        self.fs.makedir('egg')

        fs.copy.copy_structure(self.fs, mem_fs)
        expected = {
            "/egg",
            "/foo",
            "/foo/bar",
            "/foo/bar/baz",
        }
        self.assertEqual(set(walk.walk_dirs(mem_fs)), expected)
Exemple #2
0
    def test_move_same_fs(self):
        self.fs.makedirs('foo/bar/baz')
        self.fs.makedir('egg')
        self.fs.settext('top.txt', 'Hello, World')
        self.fs.settext('/foo/bar/baz/test.txt', 'Goodbye, World')

        fs.move.move_dir(self.fs, 'foo', self.fs, 'foo2')

        expected = {
            "/egg",
            "/foo2",
            "/foo2/bar",
            "/foo2/bar/baz",
        }
        self.assertEqual(set(walk.walk_dirs(self.fs)), expected)
        self.assert_text('top.txt', 'Hello, World')
        self.assert_text('/foo2/bar/baz/test.txt', 'Goodbye, World')
Exemple #3
0
    def _test_copy_dir_write(self, protocol):
        # Test copying to this filesystem from another.

        other_fs = open_fs(protocol)
        other_fs.makedirs('foo/bar/baz')
        other_fs.makedir('egg')
        other_fs.settext('top.txt', 'Hello, World')
        other_fs.settext('/foo/bar/baz/test.txt', 'Goodbye, World')
        fs.copy.copy_dir(other_fs, '/', self.fs, '/')
        expected = {
            "/egg",
            "/foo",
            "/foo/bar",
            "/foo/bar/baz",
        }
        self.assertEqual(set(walk.walk_dirs(self.fs)), expected)
        self.assert_text('top.txt', 'Hello, World')
        self.assert_text('/foo/bar/baz/test.txt', 'Goodbye, World')
Exemple #4
0
    def _test_copy_dir(self, protocol):
        # Test copy.copy_dir.

        # Test copying to a another fs
        other_fs = open_fs(protocol)
        self.fs.makedirs('foo/bar/baz')
        self.fs.makedir('egg')
        self.fs.settext('top.txt', 'Hello, World')
        self.fs.settext('/foo/bar/baz/test.txt', 'Goodbye, World')

        fs.copy.copy_dir(self.fs, '/', other_fs, '/')
        expected = {
            "/egg",
            "/foo",
            "/foo/bar",
            "/foo/bar/baz",
        }
        self.assertEqual(set(walk.walk_dirs(other_fs)), expected)
        self.assert_text('top.txt', 'Hello, World')
        self.assert_text('/foo/bar/baz/test.txt', 'Goodbye, World')

        # Test copying a sub dir
        other_fs = open_fs('mem://')
        fs.copy.copy_dir(self.fs, '/foo', other_fs, '/')
        self.assertEqual(list(walk.walk_files(other_fs)),
                         ['/bar/baz/test.txt'])

        print('BEFORE')
        self.fs.tree()
        other_fs.tree()
        fs.copy.copy_dir(self.fs, '/foo', other_fs, '/egg')

        print('FS')
        self.fs.tree()
        print('OTHER')
        other_fs.tree()
        self.assertEqual(list(walk.walk_files(other_fs)),
                         ['/bar/baz/test.txt', '/egg/bar/baz/test.txt'])