Exemple #1
0
    def test_get_files_scp(self):
        scget = SplitCopyGet()
        scget.progress = MockProgress()
        scget.copy_proto = "scp"

        result = scget.get_files(
            MockFTP,
            MockSSHShell,
            MockSCPClient,
            ["chunk0", 1999],
            "/var/tmp/foo",
            {},
        )
        assert result == None
Exemple #2
0
    def test_get_files_scp_authfail(self, monkeypatch: MonkeyPatch):
        class MockSSHShell2(MockSSHShell):
            def worker_thread_auth(self):
                return False

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scget = SplitCopyGet()
        scget.progress = MockProgress()
        scget.copy_proto = "scp"
        with raises(TransferError):
            scget.get_files(MockFTP, MockSSHShell2, MockSCPClient,
                            ["chunk0", 1999], "/tmp/", {})
Exemple #3
0
    def test_get_files_scp_fail(self, monkeypatch: MonkeyPatch):
        class MockSCPClient2(MockSCPClient):
            def get(self, *args):
                raise SCPException

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scget = SplitCopyGet()
        scget.progress = MockProgress()
        scget.copy_proto = "scp"
        with raises(TransferError):
            scget.get_files(MockFTP, MockSSHShell, MockSCPClient2,
                            ["chunk0", 1999], "/tmp/", {})
Exemple #4
0
    def test_get_files_ftp_filenotfound_fail(self, monkeypatch: MonkeyPatch):
        class MockFTP2(MockFTP):
            def get(self, *args):
                raise error_proto

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scget = SplitCopyGet()
        scget.progress = MockProgress()
        scget.copy_proto = "ftp"
        with raises(TransferError):
            scget.get_files(MockFTP2, MockSSHShell, MockSCPClient,
                            ["chunk0", 1999], "/tmp/", {})
Exemple #5
0
    def test_get_files_ftp_fail(self, monkeypatch: MonkeyPatch):
        class MockFTP2(MockFTP):
            def get(self, *args):
                raise error_proto

        def sleep(secs):
            pass

        def stat(*args):
            stat.st_size = 10000
            stat.st_mode = 1
            stat.st_mtime = None
            return stat

        monkeypatch.setattr("time.sleep", sleep)
        monkeypatch.setattr("os.stat", stat)
        scget = SplitCopyGet()
        scget.progress = MockProgress()
        scget.copy_proto = "ftp"
        with raises(TransferError):
            scget.get_files(MockFTP2, MockSSHShell, MockSCPClient,
                            ["chunk0", 1999], "/tmp/", {})