Fixed test_webui only failing in nix_sandbox also fixed test_create_flake
This commit is contained in:
@@ -21,14 +21,11 @@ def command_exec(cmd: List[str], work_dir: Path, env: Dict[str, str]) -> None:
|
||||
def block_for_input() -> None:
|
||||
log = logging.getLogger(__name__)
|
||||
procid = os.getpid()
|
||||
command = f"echo 'continue' > /sys/proc/{procid}/fd/{sys.stdin.fileno()}"
|
||||
f"echo 'continue' > /sys/proc/{procid}/fd/{sys.stdin.fileno()}"
|
||||
|
||||
while True:
|
||||
log.warning("Use sudo cntr attach <pid> to attach to the container.")
|
||||
log.warning("Resume execution by executing '%s' in cntr shell", command)
|
||||
res = input("Input 'continue' to resume execution: ")
|
||||
if res == "continue":
|
||||
break
|
||||
# log.warning("Resume execution by executing '%s' in cntr shell", command)
|
||||
time.sleep(1)
|
||||
log.info("Resuming execution.")
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_create_flake_api(
|
||||
response = api.post(
|
||||
"/api/flake/create",
|
||||
json=dict(
|
||||
dest=str(flake_dir),
|
||||
flake_name=str(flake_dir),
|
||||
url=str(DEFAULT_URL),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1,44 +1,13 @@
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from api import TestClient
|
||||
from fixtures_flakes import FlakeForTest
|
||||
|
||||
from clan_cli.flakes.create import DEFAULT_URL
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_flake_create(api: TestClient, temporary_home: Path) -> None:
|
||||
params = {"flake_name": "defaultFlake", "url": str(DEFAULT_URL)}
|
||||
response = api.post(
|
||||
"/api/flake/create",
|
||||
json=params,
|
||||
)
|
||||
|
||||
response.json()
|
||||
assert response.status_code == 201, "Failed to create flake"
|
||||
|
||||
|
||||
# @pytest.mark.impure
|
||||
# def test_flake_create_fail(api: TestClient, temporary_home: Path) -> None:
|
||||
# params = {
|
||||
# "flake_name": "../../../defaultFlake/",
|
||||
# "url": str(DEFAULT_URL)
|
||||
# }
|
||||
# response = api.post(
|
||||
# "/api/flake/create",
|
||||
# json=params,
|
||||
# )
|
||||
|
||||
# data = response.json()
|
||||
# log.debug("Data: %s", data)
|
||||
# assert response.status_code == 422, "This should have failed"
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_inspect_ok(api: TestClient, test_flake_with_core: FlakeForTest) -> None:
|
||||
params = {"url": str(test_flake_with_core.path)}
|
||||
|
||||
@@ -5,13 +5,12 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from cli import Cli
|
||||
from ports import PortFunction
|
||||
|
||||
from clan_cli.debug import breakpoint_container
|
||||
|
||||
|
||||
# @pytest.mark.timeout(10)
|
||||
@pytest.mark.timeout(10)
|
||||
def test_start_server(unused_tcp_port: PortFunction, temporary_home: Path) -> None:
|
||||
Cli()
|
||||
port = unused_tcp_port()
|
||||
@@ -38,15 +37,16 @@ echo "1" > {fifo}
|
||||
env["PATH"] = f"{temporary_home}:{env['PATH']}"
|
||||
|
||||
# Add build/src to PYTHONPATH so that the webui module is found in nix sandbox
|
||||
# TODO: We need a way to make sure things which work in the devshell also work in the sandbox
|
||||
python_path = env.get("PYTHONPATH")
|
||||
if python_path:
|
||||
env["PYTHONPATH"] = f"/build/src:{python_path}"
|
||||
|
||||
breakpoint_container(
|
||||
cmd=[sys.executable, "-m", "clan_cli.webui", "--port", str(port)],
|
||||
env=env,
|
||||
work_dir=temporary_home,
|
||||
)
|
||||
# breakpoint_container(
|
||||
# cmd=[sys.executable, "-m", "clan_cli.webui", "--port", str(port)],
|
||||
# env=env,
|
||||
# work_dir=temporary_home,
|
||||
# )
|
||||
|
||||
with subprocess.Popen(
|
||||
[sys.executable, "-m", "clan_cli.webui", "--port", str(port)],
|
||||
|
||||
Reference in New Issue
Block a user