53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
import pytest
|
|
|
|
from .test_helpers import DummyContext
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_run_tests_async_forwards_params(monkeypatch):
|
|
from services.tools.test_jobs import run_tests_async
|
|
|
|
captured = {}
|
|
|
|
async def fake_send_with_unity_instance(send_fn, unity_instance, command_type, params, **kwargs):
|
|
captured["command_type"] = command_type
|
|
captured["params"] = params
|
|
return {"success": True, "data": {"job_id": "abc123", "status": "running"}}
|
|
|
|
import services.tools.test_jobs as mod
|
|
monkeypatch.setattr(mod.unity_transport, "send_with_unity_instance", fake_send_with_unity_instance)
|
|
|
|
resp = await run_tests_async(
|
|
DummyContext(),
|
|
mode="EditMode",
|
|
test_names="MyNamespace.MyTests.TestA",
|
|
include_details=True,
|
|
)
|
|
assert captured["command_type"] == "run_tests_async"
|
|
assert captured["params"]["mode"] == "EditMode"
|
|
assert captured["params"]["testNames"] == ["MyNamespace.MyTests.TestA"]
|
|
assert captured["params"]["includeDetails"] is True
|
|
assert resp["success"] is True
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_test_job_forwards_job_id(monkeypatch):
|
|
from services.tools.test_jobs import get_test_job
|
|
|
|
captured = {}
|
|
|
|
async def fake_send_with_unity_instance(send_fn, unity_instance, command_type, params, **kwargs):
|
|
captured["command_type"] = command_type
|
|
captured["params"] = params
|
|
return {"success": True, "data": {"job_id": params["job_id"], "status": "running"}}
|
|
|
|
import services.tools.test_jobs as mod
|
|
monkeypatch.setattr(mod.unity_transport, "send_with_unity_instance", fake_send_with_unity_instance)
|
|
|
|
resp = await get_test_job(DummyContext(), job_id="job-1")
|
|
assert captured["command_type"] == "get_test_job"
|
|
assert captured["params"]["job_id"] == "job-1"
|
|
assert resp["data"]["job_id"] == "job-1"
|
|
|
|
|