def test_update_package_code(tmp_path: Path) -> None: # we use in this test msi file from the tst_files, not from site tgt = tmp_path / "check_mk_agent.msi" try: root_path = Path("agents/wnx/test_files/msibuild/msi") assert root_path.exists() src = root_path / "check_mk_agent.msi" assert src.exists() content = src.read_bytes() pos_initial = content.find(b"4E18343A-5E32-1") assert pos_initial != -1 if tgt.exists(): tgt.unlink() # random uuid assert not tgt.exists() assert msi_engine.copy_file_safe(src, tgt) msi_engine.update_package_code(tgt) tgt_content = tgt.read_bytes() assert tgt_content.find(b"4E18343A-5E32-1") == -1 if tgt.exists(): tgt.unlink() # case for the uuid in command line assert not tgt.exists() assert msi_engine.copy_file_safe(src, tgt) msi_engine.update_package_code( tgt, "{01234567-1234-1234-1234-012345678901}") tgt_content = tgt.read_bytes() pos = tgt_content.find(b"01234567-1234-1234") assert pos == pos_initial if tgt.exists(): tgt.unlink() # case for the hash assert not tgt.exists() assert msi_engine.copy_file_safe(src, tgt) msi_engine.update_package_code(tgt, "012") tgt_content = tgt.read_bytes() pos = tgt_content.find(b"21FAC8EF-8042-50CA-8C85-FBCA566E726E") assert pos == pos_initial finally: if tgt.exists(): tgt.unlink()
def test_make_msi_copy(tmp_path: Path) -> None: src_file = Path(tmp_path, "temp.in") with src_file.open("w") as s: s.write("+++") dst_file = Path(tmp_path, "temp.out") assert msi_engine.copy_file_safe(src_file, dst_file) assert dst_file.exists() with dst_file.open("r") as d: content = d.read() assert content == "+++"