Esempio n. 1
0
    def test_validate_remote_path_put_isdir(self):
        class MockSSHShell2(MockSSHShell):
            def run(cmd):
                return (True, "")

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2
        scput.local_file = "foo"
        scput.remote_path = "/var/tmp"
        result = scput.validate_remote_path_put()
        assert result == None
Esempio n. 2
0
    def test_validate_remote_path_existingfile_basename_match(self):
        class MockSSHShell2(MockSSHShell):
            def run(cmd):
                if re.match(r"test -d", cmd):
                    return False, ""
                else:
                    return True, ""

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2
        scput.local_file = "foo"
        scput.remote_path = "/var/tmp/foo"
        result = scput.validate_remote_path_put()
        assert result == None
Esempio n. 3
0
    def test_validate_remote_path_put_fail(self, monkeypatch: MonkeyPatch):
        class MockSSHShell2(MockSSHShell):
            def run(cmd):
                return (False, "")

        def dirname(path):
            return "/var/tmp"

        monkeypatch.setattr("os.path.dirname", dirname)
        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2
        scput.scs = MockSplitCopyShared()
        scput.local_file = "foo"
        scput.remote_path = "/var/tmp/foo"
        with raises(SystemExit):
            scput.validate_remote_path_put()
Esempio n. 4
0
    def test_validate_remote_path_put_newfile_basename_nomatch(self):
        class MockSSHShell2(MockSSHShell):
            self.instance = 0

            def run(cmd):
                if re.match(r"test -d", cmd) and not self.instance:
                    self.instance += 1
                    return False, ""
                elif re.match(r"test -d", cmd):
                    return True, ""
                else:
                    return False, ""

        scput = SplitCopyPut()
        scput.sshshell = MockSSHShell2
        scput.local_file = "foo"
        scput.remote_path = "/var/tmp/bar"
        result = scput.validate_remote_path_put()
        assert result == None