diff --git a/odoo_devkit/local_runtime.py b/odoo_devkit/local_runtime.py index 68dda1c..54517d0 100644 --- a/odoo_devkit/local_runtime.py +++ b/odoo_devkit/local_runtime.py @@ -16,8 +16,8 @@ from typing import TextIO from .artifact_inputs import ( - ArtifactInputsError, ArtifactInputsDefinition, + ArtifactInputsError, effective_artifact_input_sources, load_artifact_inputs_definition, ) @@ -1119,7 +1119,7 @@ def load_environment_from_control_plane( "--directory", str(control_plane_root), "run", - "control-plane", + "launchplane", "environments", "resolve", "--context", diff --git a/tests/test_control_plane_cli_contract.py b/tests/test_control_plane_cli_contract.py new file mode 100644 index 0000000..0e620ff --- /dev/null +++ b/tests/test_control_plane_cli_contract.py @@ -0,0 +1,48 @@ +from __future__ import annotations + +import json +import unittest +from pathlib import Path +from unittest import mock + +from odoo_devkit import local_runtime + + +class ControlPlaneCliContractTests(unittest.TestCase): + def test_environment_resolution_uses_launchplane_cli(self) -> None: + completed_process = mock.Mock( + returncode=0, + stdout=json.dumps( + { + "environment": { + "ODOO_MASTER_PASSWORD": "control-plane-master", + } + } + ), + stderr="", + ) + + with mock.patch( + "odoo_devkit.local_runtime.subprocess.run", + return_value=completed_process, + ) as run_mock: + loaded_environment = local_runtime.load_environment_from_control_plane( + control_plane_root=Path("/opt/launchplane"), + context_name="cm", + instance_name="testing", + ) + + command = run_mock.call_args.args[0] + self.assertEqual( + command[:5], + ["uv", "--directory", "/opt/launchplane", "run", "launchplane"], + ) + self.assertIn("environments", command) + self.assertEqual( + loaded_environment.merged_values["ODOO_MASTER_PASSWORD"], + "control-plane-master", + ) + + +if __name__ == "__main__": + unittest.main()