Keep source, config, and deploy files. Leave runtime data, uploads, and logs out of git. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import pytest
|
|
|
|
from kamidso.application.run_registry import ActiveRunRegistry
|
|
from kamidso.application.run_service import RunService
|
|
from kamidso.contracts.run import ExecutionStep, KamidsoRun
|
|
from kamidso.repositories.store import RepositoryStore
|
|
|
|
|
|
def test_public_run_keeps_the_latest_step_for_each_id():
|
|
run = KamidsoRun(
|
|
id="run_1",
|
|
conversation_id="conv_1",
|
|
user_id="usr_1",
|
|
workspace_id="ws_1",
|
|
steps=[
|
|
ExecutionStep(id="step-3", type="tool_call", title="اجرای ابزار"),
|
|
ExecutionStep(id="step-3", type="code_execution", title="تحلیل داده"),
|
|
ExecutionStep(id="step-4", type="file_inspection", title="بررسی فایل"),
|
|
],
|
|
)
|
|
steps = run.to_public_dict()["steps"]
|
|
assert [step["id"] for step in steps] == ["step-3", "step-4"]
|
|
assert steps[0]["title"] == "تحلیل داده"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_second_step_started_updates_the_same_row():
|
|
store = RepositoryStore()
|
|
service = RunService(store, ActiveRunRegistry(), None) # type: ignore[arg-type]
|
|
run = KamidsoRun(
|
|
id="run_1",
|
|
conversation_id="conv_1",
|
|
user_id="usr_1",
|
|
workspace_id="ws_1",
|
|
)
|
|
await store.create_run(run)
|
|
service._active.register(run)
|
|
await service.update_from_event(
|
|
run,
|
|
{"type": "step.started", "id": "step-3", "title": "اجرای ابزار", "step_type": "tool_call"},
|
|
)
|
|
await service.update_from_event(
|
|
run,
|
|
{
|
|
"type": "step.started",
|
|
"id": "step-3",
|
|
"title": "تحلیل داده",
|
|
"step_type": "code_execution",
|
|
},
|
|
)
|
|
await service.update_from_event(run, {"type": "step.completed", "id": "step-3"})
|
|
assert len(run.steps) == 1
|
|
assert run.steps[0].title == "تحلیل داده"
|
|
assert run.steps[0].status == "completed"
|