diff --git a/tests/test_transfer.py b/tests/test_transfer.py index 0d3c98a..d8ead10 100644 --- a/tests/test_transfer.py +++ b/tests/test_transfer.py @@ -80,6 +80,53 @@ def test_file_transfer_binary(address: str, timeout: float): lsv2.disconnect() +def test_file_transfer_comp_mode(address: str, timeout: float): + """test if transferring a file in binary mode with active compatibility mode works""" + lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True, compatibility_mode=True) + lsv2.connect() + + with tempfile.TemporaryDirectory(suffix=None, prefix="pyLSV2_") as tmp_dir_name: + local_send_path = Path("./data/testdata.bmp") + local_recive_path = Path(tmp_dir_name).joinpath("test.bmp") + remote_path = pyLSV2.DriveName.TNC + pyLSV2.PATH_SEP + local_send_path.name + + assert lsv2.file_info(remote_path) is not True + + assert ( + lsv2.send_file( + local_path=local_send_path, + remote_path=remote_path, + override_file=True, + binary_mode=True, + ) + is True + ) + + assert ( + lsv2.recive_file( + local_path=str(local_recive_path), + remote_path=remote_path, + override_file=True, + binary_mode=True, + ) + is True + ) + + assert lsv2.delete_file(remote_path) is True + + digests = [] + for filename in [local_send_path, local_recive_path]: + hasher = hashlib.md5() + with open(filename, "rb") as f_p: + buf = f_p.read() + hasher.update(buf) + h_d = hasher.hexdigest() + digests.append(h_d) + assert (digests[0] == digests[1]) is True + + lsv2.disconnect() + + def test_recive_with_path_formating(address: str, timeout: float): """test if reading of file information with / instead of \\ as path separator""" lsv2 = pyLSV2.LSV2(address, port=19000, timeout=timeout, safe_mode=True)