def test_walk_files(self): source_files = sorted(walk.walk_files(self.source_fs)) archive_files = sorted(walk.walk_files(self.fs)) self.assertEqual( source_files, archive_files )
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'])