コード例 #1
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
 def test_put_files_scp(self):
     scput = SplitCopyPut()
     scput.progress = MockProgress()
     scput.copy_proto = "scp"
     result = scput.put_files(MockFTP, MockSSHShell, MockSCPClient,
                              ["chunk0", 1999], "/tmp/", {})
     assert result == None
コード例 #2
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
    def test_put_noverify(self, monkeypatch: MonkeyPatch):
        scput = SplitCopyPut()
        scput.scs = MockSplitCopyShared()
        scput.progress = MockProgress()

        def validate_remote_path_put():
            pass

        def check_target_exists():
            return True

        def delete_target_remote():
            pass

        def determine_local_filesize():
            return 1000000

        def split_file_local(*args):
            pass

        def get_chunk_info():
            return [["chunk0", 1000], ["chunk1", 1000]]

        def put_files(*args):
            pass

        def join_files_remote(*args):
            pass

        def compare_file_sizes(*args):
            pass

        def inc_percentage():
            for n in range(90, 101):
                time.sleep(0.1)
                scput.progress.totals["percent_done"] = n

        scput.noverify = True
        monkeypatch.setattr(scput, "validate_remote_path_put",
                            validate_remote_path_put)
        monkeypatch.setattr(scput, "check_target_exists", check_target_exists)
        monkeypatch.setattr(scput, "delete_target_remote",
                            delete_target_remote)
        monkeypatch.setattr(scput, "determine_local_filesize",
                            determine_local_filesize)
        monkeypatch.setattr(scput, "split_file_local", split_file_local)
        monkeypatch.setattr(scput, "get_chunk_info", get_chunk_info)
        monkeypatch.setattr(scput, "put_files", put_files)
        monkeypatch.setattr(scput, "join_files_remote", join_files_remote)
        monkeypatch.setattr(scput, "compare_file_sizes", compare_file_sizes)
        thread = Thread(
            name="inc_percentage_done",
            target=inc_percentage,
        )
        thread.start()
        result = scput.put()
        thread.join()
        assert isinstance(result[0], datetime.datetime) and isinstance(
            result[1], datetime.datetime)
コード例 #3
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
    def test_put_files_scp_auth_fail(self, monkeypatch: MonkeyPatch):
        class MockSSHShell2(MockSSHShell):
            def worker_thread_auth(self):
                return False

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scput = SplitCopyPut()
        scput.progress = MockProgress()
        scput.copy_proto = "scp"
        with raises(TransferError):
            scput.put_files(MockFTP, MockSSHShell2, MockSCPClient,
                            ["chunk0", 1999], "/tmp/", {})
コード例 #4
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
    def test_put_files_scp_fail(self, monkeypatch: MonkeyPatch):
        class MockSCPClient2(MockSCPClient):
            def put(self, *args):
                raise SCPException

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scput = SplitCopyPut()
        scput.progress = MockProgress()
        scput.copy_proto = "scp"
        with raises(TransferError):
            scput.put_files(MockFTP, MockSSHShell, MockSCPClient2,
                            ["chunk0", 1999], "/tmp/", {})
コード例 #5
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
    def test_put_files_ftp_sendcmd_fail(self, monkeypatch: MonkeyPatch):
        class MockFTP2(MockFTP):
            def put(self, *args):
                raise error_proto

            def sendcmd(self, cmd):
                raise error_proto

        def sleep(secs):
            pass

        monkeypatch.setattr("time.sleep", sleep)
        scput = SplitCopyPut()
        scput.progress = MockProgress()
        scput.copy_proto = "ftp"
        with raises(TransferError):
            scput.put_files(MockFTP2, MockSSHShell, MockSCPClient,
                            ["chunk0", 1999], "/tmp/", {})
コード例 #6
0
ファイル: test_put.py プロジェクト: Juniper/splitcopy
    def test_put_fail(self, monkeypatch: MonkeyPatch):
        scput = SplitCopyPut()
        scput.scs = MockSplitCopyShared()
        scput.progress = MockProgress()

        def validate_remote_path_put():
            pass

        def check_target_exists():
            return True

        def delete_target_remote():
            pass

        def determine_local_filesize():
            return 1000000

        def local_sha_put():
            return "sha384sum", 384, "abcdef0123456789"

        def split_file_local(*args):
            pass

        def get_chunk_info():
            return [["chunk0", 1000], ["chunk1", 1000]]

        def put_files(*args):
            raise TransferError

        monkeypatch.setattr(scput, "validate_remote_path_put",
                            validate_remote_path_put)
        monkeypatch.setattr(scput, "check_target_exists", check_target_exists)
        monkeypatch.setattr(scput, "delete_target_remote",
                            delete_target_remote)
        monkeypatch.setattr(scput, "determine_local_filesize",
                            determine_local_filesize)
        monkeypatch.setattr(scput, "local_sha_put", local_sha_put)
        monkeypatch.setattr(scput, "split_file_local", split_file_local)
        monkeypatch.setattr(scput, "get_chunk_info", get_chunk_info)
        monkeypatch.setattr(scput, "put_files", put_files)

        with raises(SystemExit):
            scput.put()