import pathlib import subprocess ROOT = pathlib.Path(__file__).resolve().parents[2] def run_shell(script: str) -> str: result = subprocess.run( ["bash", "-c", script], cwd=ROOT, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) return result.stdout.strip() def test_shell_service_endpoint_helper_defaults_and_normalizes_urls(): output = run_shell( "source scripts/lib/service-endpoints.sh; " "droboticflow_default_api_base_url; " "droboticflow_default_worker_base_url; " "droboticflow_first_service_url '' 'https://api.example.test///'" ) assert output.splitlines() == [ "http://127.0.0.1:3001", "http://127.0.0.1:3002", "https://api.example.test", ] def test_shell_service_endpoint_helper_rejects_invalid_urls(): result = subprocess.run( [ "bash", "-c", "source scripts/lib/service-endpoints.sh; droboticflow_first_service_url 'ftp://api.example.test'", ], cwd=ROOT, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) assert result.returncode == 2 assert "absolute http(s) URL" in result.stderr