forked from longtao.wu/droboticflow
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import os
|
|
import pathlib
|
|
import subprocess
|
|
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parents[2]
|
|
SCRIPT = ROOT / "scripts" / "smoke-test.sh"
|
|
|
|
|
|
def run_smoke(extra_env: dict[str, str]) -> subprocess.CompletedProcess:
|
|
env = os.environ.copy()
|
|
for key in (
|
|
"API_BASE_URL",
|
|
"BASE_URL",
|
|
"SMOKE_REQUIRE_EXPLICIT_ENDPOINT",
|
|
"SMOKE_RUN_TIMEOUT_SECONDS",
|
|
"SMOKE_SOURCE_PATH",
|
|
"WORKER_API_BASE_URL",
|
|
"WORKER_BASE_URL",
|
|
):
|
|
env.pop(key, None)
|
|
env.update(extra_env)
|
|
return subprocess.run(["bash", str(SCRIPT)], cwd=ROOT, env=env, text=True, capture_output=True, check=False)
|
|
|
|
|
|
def test_smoke_requires_explicit_endpoint_when_deployed_mode_is_enabled():
|
|
result = run_smoke({"SMOKE_REQUIRE_EXPLICIT_ENDPOINT": "true", "SMOKE_SOURCE_PATH": "/workspace/real-data"})
|
|
|
|
assert result.returncode == 1
|
|
assert "API_BASE_URL or BASE_URL is required when SMOKE_REQUIRE_EXPLICIT_ENDPOINT=true" in result.stderr
|
|
|
|
|
|
def test_smoke_rejects_invalid_explicit_endpoint_mode_boolean():
|
|
result = run_smoke({"SMOKE_REQUIRE_EXPLICIT_ENDPOINT": "maybe", "SMOKE_SOURCE_PATH": "/workspace/real-data"})
|
|
|
|
assert result.returncode == 1
|
|
assert "SMOKE_REQUIRE_EXPLICIT_ENDPOINT must be a boolean" in result.stderr
|