コード例 #1
0
    def test_initialization(self):
        m = Move(source_path="source", target_path="target")
        assert m.source_path == "source"
        assert m.target_path == "target"

        m = Move()
        assert m.source_path == ""
        assert m.target_path == ""
コード例 #2
0
    def test_run_move_directory_to_directory(self, tmpdir):
        source = tmpdir.mkdir("source").mkdir("test")

        m = Move(str(source), str(tmpdir))
        res = m.run()
        exp = tmpdir.join("test")
        assert res == Path(str(exp))
        assert exp.exists()
        assert exp.isdir()
        assert not source.exists()
コード例 #3
0
    def test_run_move_file_to_file(self, tmpdir):
        source = tmpdir.mkdir("source").join("test")
        source.write_binary(b"test")

        target = tmpdir.join("out")

        m = Move(str(source), str(target))
        res = m.run()
        assert res == Path(str(target))
        assert target.exists()
        assert not source.exists()
コード例 #4
0
 def test_target_path_not_provided(self, tmpdir):
     m = Move(source_path="lala")
     with pytest.raises(ValueError, match="No `target_path` provided"):
         m.run()
コード例 #5
0
 def test_source_path_not_provided(self, tmpdir):
     m = Move()
     with pytest.raises(ValueError, match="No `source_path` provided"):
         m.run()