"""Check the built wheel with the real Repeater plugin parser. Usage: git clone --no-checkout https://github.com/openhop-dev/openhop_repeater.git repeater-source git -C repeater-source checkout --detach 13eb8b2ea8b1cdb4a07ed6e282dc99e3aa8a5a8b PYTHONPATH=repeater-source python scripts/validate_wheel.py dist/*.whl """ import json import sys from pathlib import Path from tempfile import TemporaryDirectory from zipfile import ZipFile from repeater.plugins.manifest import load_manifest_from_wheel from repeater.plugins.storage import PluginStorage PLUGIN_ID = "rickelobe.influxdb" ENTRYPOINT = "openhop-influxdb" wheel = Path(sys.argv[1]) manifest = load_manifest_from_wheel(wheel) assert manifest.id == PLUGIN_ID, manifest.id assert manifest.runtime.type == "python" assert manifest.runtime.entrypoint == ENTRYPOINT with ZipFile(wheel) as archive: names = archive.namelist() manifests = [n for n in names if n.endswith("/openhop-plugin.json")] assert len(manifests) == 1 and f"share/openhop/plugins/{PLUGIN_ID}/" in manifests[0], manifests dist_info = next(n for n in names if n.endswith(".dist-info/entry_points.txt")) entry_points = archive.read(dist_info).decode() assert f"{ENTRYPOINT} = openhop_influxdb_plugin.main:main" in entry_points, entry_points defaults_name = next(n for n in names if n.endswith(f"/{PLUGIN_ID}/config.default.json")) defaults = json.loads(archive.read(defaults_name)) assert manifest.version == wheel.name.split("-")[1], (manifest.version, wheel.name) with TemporaryDirectory(prefix="influxdb-plugin-validation-") as root: storage = PluginStorage(Path(root) / "plugins") storage.ensure_plugin_layout(manifest.id, manifest.version) storage.write_manifest(manifest.id, manifest.version, manifest) storage.set_current(manifest.id, manifest.version) storage.write_config(manifest.id, manifest.config_defaults) assert storage.load_current_manifest(manifest.id) == manifest assert storage.read_config(manifest.id) == defaults print(f"PASS: {wheel.name} manifest, entrypoint, defaults and storage round-trip")