droboticflow/tests/backend/test_operator_manifest_selection.py

41 lines
1.5 KiB
Python

"""A scoped publication validates its own release; the full check stays strict."""
import pytest
from scripts import generate_operator_repository_manifests as manifests
def test_package_publication_checks_its_actual_release_without_loading_other_releases(monkeypatch):
load = manifests.load_release
calls = []
def selected(slug):
calls.append(slug)
if slug != "package":
raise RuntimeError("unrelated release must still fail the full check")
return load(slug)
monkeypatch.setattr(manifests, "load_release", selected)
generated = manifests.expected_manifests({"package"})
assert calls == ["package"]
assert len(generated) == 2
assert all(path.parent.name == "package" for path in generated)
assert all(value["operatorId"] == "operator-builtin-package" for value in generated.values())
with pytest.raises(RuntimeError, match="unrelated release"):
manifests.expected_manifests()
@pytest.mark.parametrize("selection", [set(), {"not-an-operator"}, {"../package"}, {"temporal_causal_eval"}])
def test_unknown_or_empty_selection_cannot_silently_pass(selection):
with pytest.raises(RuntimeError, match="selection"):
manifests.expected_manifests(selection)
def test_selected_release_errors_are_not_ignored(monkeypatch):
def invalid(_slug):
raise RuntimeError("selected digest drift")
monkeypatch.setattr(manifests, "load_release", invalid)
with pytest.raises(RuntimeError, match="selected digest drift"):
manifests.expected_manifests({"package"})