Пример #1
0
def test_patch_package_code_by_state_file(conf_dir, cmk_dir):
    # prepare file to tests
    if not cmk_dir.exists():
        pytest.skip("cmk_dir is not good")
    fname = u"test_bin.tst"
    src = cmk_dir / u"agents/wnx/test_files/msibuild/msi" / fname
    if not src.exists():
        pytest.skip("Path with MSI doesn't exist")

    uuid = msi_patch.generate_uuid()

    # prepare test file
    dst = conf_dir / fname
    shutil.copy(str(src), str(dst))
    base_content = dst.read_bytes()
    assert base_content.find(msi_patch.TRADITIONAL_UUID.encode('ascii')) != -1

    # patch 1, patching is successful
    p = conf_dir / "msi_state.yml"
    msi_patch.write_state_file(p, 4, msi_patch.TRADITIONAL_UUID)
    assert msi_patch.patch_package_code_by_state_file(f_name=dst, package_code=uuid, state_file=p)

    assert dst.stat().st_size == src.stat().st_size

    new_content = dst.read_bytes()
    assert new_content.find(uuid.encode('ascii')) == 4
Пример #2
0
def test_patch_package_code_by_state_file(conf_dir):
    # prepare file to tests
    fname = u"test_bin.tst"
    src = _get_test_file(fname=fname)

    uuid = msi_patch.generate_uuid()

    # prepare test file
    dst = conf_dir / fname
    shutil.copy(str(src), str(dst))
    base_content = dst.read_bytes()
    assert base_content.find(msi_patch.TRADITIONAL_UUID.encode('ascii')) != -1

    # patch 1, patching is successful
    p = conf_dir / "msi_state.yml"
    msi_patch.write_state_file(p, 4, msi_patch.TRADITIONAL_UUID)
    assert msi_patch.patch_package_code_by_state_file(f_name=dst, package_code=uuid, state_file=p)

    assert dst.stat().st_size == src.stat().st_size

    new_content = dst.read_bytes()
    assert new_content.find(uuid.encode('ascii')) == 4