Fix agent plugin configuration handling
CI / php-store (push) Waiting to run
CI / python-components (push) Waiting to run

This commit is contained in:
2026-08-24 23:10:02 +02:00
parent 541f107e1e
commit acadcdfeee
9 changed files with 231 additions and 157 deletions
+39 -15
View File
@@ -93,22 +93,25 @@ class FakeRunner:
def runtime(root: Path, *, execution_mode="direct", allow=True):
config = root / "configuration.py"
config.write_text("PLUGINS = ['netbox_plugin_store']\n", encoding="utf-8")
values = {
"store_url": "https://store.example",
"allowed_store_urls": ["https://store.example"],
"allowed_artifact_urls": ["https://store.example"],
"configuration_path": str(config),
"requirements_path": str(root / "local_requirements.txt"),
"manage_path": str(root / "manage.py"),
"lock_path": str(root / "operation.lock"),
"backup_dir": str(root / "backups"),
"execution_mode": execution_mode,
"allow_lifecycle_mutations": allow,
"run_migrations": False,
"collect_static": False,
"allow_package_index": False,
}
if execution_mode == "agent":
values["agent_socket_path"] = str(root / "agent.sock")
return RuntimeSettings.from_mapping(
{
"store_url": "https://store.example",
"allowed_store_urls": ["https://store.example"],
"allowed_artifact_urls": ["https://store.example"],
"configuration_path": str(config),
"requirements_path": str(root / "local_requirements.txt"),
"manage_path": str(root / "manage.py"),
"lock_path": str(root / "operation.lock"),
"backup_dir": str(root / "backups"),
"execution_mode": execution_mode,
"allow_lifecycle_mutations": allow,
"run_migrations": False,
"collect_static": False,
"allow_package_index": False,
},
values,
configuration_dir=root,
netbox_root=root,
base_dir=root,
@@ -117,6 +120,27 @@ def runtime(root: Path, *, execution_mode="direct", allow=True):
class LifecycleTests(unittest.TestCase):
def test_agent_mode_does_not_parse_agent_managed_plugins_from_configuration(self):
with tempfile.TemporaryDirectory() as temp_name:
root = Path(temp_name)
settings = runtime(root, execution_mode="agent")
settings.configuration_path.write_text(
"PLUGINS = ['netbox_plugin_store']\nPLUGINS = list(PLUGINS)\n",
encoding="utf-8",
)
service = LifecycleService(
settings,
FakeClient(catalog_plugin()),
FakeRepository(),
runner=FakeRunner(),
version_provider=lambda _: "",
runtime_active_provider=lambda _: False,
)
result = service.execute(LifecycleRequest("example-plugin", "install", "1.0.0", True))
self.assertEqual(result.state, "dry-run")
def test_dry_run_has_no_download_or_subprocess(self):
with tempfile.TemporaryDirectory() as temp_name:
root = Path(temp_name)