File: test_move.py

package info (click to toggle)
python-fs 2.4.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,276 kB
  • sloc: python: 11,724; makefile: 226; sh: 3
file content (35 lines) | stat: -rw-r--r-- 937 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

from __future__ import unicode_literals

import unittest

import fs.move
from fs import open_fs


class TestMove(unittest.TestCase):
    def test_move_fs(self):
        src_fs = open_fs("mem://")
        src_fs.makedirs("foo/bar")
        src_fs.touch("test.txt")
        src_fs.touch("foo/bar/baz.txt")

        dst_fs = open_fs("mem://")
        fs.move.move_fs(src_fs, dst_fs)

        self.assertTrue(dst_fs.isdir("foo/bar"))
        self.assertTrue(dst_fs.isfile("test.txt"))
        self.assertTrue(src_fs.isempty("/"))

    def test_copy_dir(self):
        src_fs = open_fs("mem://")
        src_fs.makedirs("foo/bar")
        src_fs.touch("test.txt")
        src_fs.touch("foo/bar/baz.txt")

        dst_fs = open_fs("mem://")
        fs.move.move_dir(src_fs, "/foo", dst_fs, "/")

        self.assertTrue(dst_fs.isdir("bar"))
        self.assertTrue(dst_fs.isfile("bar/baz.txt"))
        self.assertFalse(src_fs.exists("foo"))