This commit is contained in:
lda
2026-06-15 22:37:59 +07:00 Verified
parent fe0b2b4f4d
commit e8152fd4e6
32 changed files with 138 additions and 84 deletions
@@ -68,7 +68,9 @@ def test_browser_click_source_human_timeout_cleans_up() -> None:
assert _active_session_count() == 0
EXAMPLE_DIR = Path(__file__).resolve().parents[2] / "examples" / "browser_click_workflow"
EXAMPLE_DIR = (
Path(__file__).resolve().parents[2] / "examples" / "browser_click_workflow"
)
@pytest.mark.asyncio
@@ -234,4 +236,3 @@ async def test_browser_click_workflow_artifact_deployment_run_path(tmp_path) ->
assert run["output"]["after"]["status_text"] == "Button clicked"
assert run["output"]["closed"] is True
assert run["trace_count"] >= 3
+3 -1
View File
@@ -103,7 +103,9 @@ async def test_call_openapi_operation_maps_unexpected_status() -> None:
@pytest.mark.asyncio
async def test_call_openapi_operation_maps_invalid_request_to_validation_error() -> None:
async def test_call_openapi_operation_maps_invalid_request_to_validation_error() -> (
None
):
app = load_openapi_app(FIXTURE)
operation = next(
op for op in load_openapi_operations(FIXTURE) if op.name == "create_pet"
-1
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
from pathlib import Path
from typing import Any
+24 -15
View File
@@ -2,7 +2,6 @@
from __future__ import annotations
import asyncio
from dataclasses import replace
from pathlib import Path
from typing import Any, cast
@@ -98,27 +97,27 @@ def _deployment_api(
context = context_from_service(service)
return WorkflowDeploymentApi(context), service
@pytest.mark.asyncio
async def test_save_deployment_stores_and_returns_stable_fields(tmp_path: Path) -> None:
artifact_store = FileWorkflowArtifactStore(tmp_path / "deploy_save")
api, _service = _deployment_api(artifact_store)
result = await api.save_deployment(
WorkflowDeployment(
id="echo.personal",
artifact_id="echo",
artifact_version=1,
bindings=[
{"logical_source": "demo", "concrete_source": "demo.personal"}
],
).model_dump(mode="json")
)
WorkflowDeployment(
id="echo.personal",
artifact_id="echo",
artifact_version=1,
bindings=[{"logical_source": "demo", "concrete_source": "demo.personal"}],
).model_dump(mode="json")
)
assert result["saved"] is True
assert result["deployment_id"] == "echo.personal"
assert result["artifact_id"] == "echo"
assert result["artifact_version"] == 1
@pytest.mark.asyncio
async def test_list_deployments_returns_compact_summaries(tmp_path: Path) -> None:
artifact_store = FileWorkflowArtifactStore(tmp_path / "deploy_list")
@@ -141,7 +140,9 @@ async def test_list_deployments_returns_compact_summaries(tmp_path: Path) -> Non
@pytest.mark.asyncio
async def test_list_deployments_returns_empty_without_artifact_store(tmp_path: Path) -> None:
async def test_list_deployments_returns_empty_without_artifact_store(
tmp_path: Path,
) -> None:
artifact_store = FileWorkflowArtifactStore(tmp_path / "deploy_no_store")
_api, service = _deployment_api(artifact_store)
context = replace(context_from_service(service), artifact_store=None)
@@ -173,7 +174,9 @@ async def test_delete_deployment_removes_one(tmp_path: Path) -> None:
@pytest.mark.asyncio
async def test_validate_deployment_returns_runnable_for_valid_binding(tmp_path: Path) -> None:
async def test_validate_deployment_returns_runnable_for_valid_binding(
tmp_path: Path,
) -> None:
artifact_store = FileWorkflowArtifactStore(tmp_path / "deploy_validate_runnable")
api, service = _deployment_api(artifact_store, register_echo=True)
artifact_store.save_artifact(_echo_artifact())
@@ -186,7 +189,9 @@ async def test_validate_deployment_returns_runnable_for_valid_binding(tmp_path:
)
)
result = await api.validate_deployment(deployment_id="echo.personal", live_check=False)
result = await api.validate_deployment(
deployment_id="echo.personal", live_check=False
)
assert result["status"] == "runnable"
assert result["diagnostics"] == []
@@ -202,7 +207,9 @@ class FailingLivenessAdapter:
@pytest.mark.asyncio
async def test_validate_deployment_live_check_calls_live_checker(tmp_path: Path) -> None:
async def test_validate_deployment_live_check_calls_live_checker(
tmp_path: Path,
) -> None:
artifact_store = FileWorkflowArtifactStore(tmp_path / "deploy_validate_live")
api, service = _deployment_api(artifact_store, register_echo=True)
artifact_store.save_artifact(_echo_artifact())
@@ -219,7 +226,9 @@ async def test_validate_deployment_live_check_calls_live_checker(tmp_path: Path)
cast(BackendAdapter, FailingLivenessAdapter()),
)
result = await api.validate_deployment(deployment_id="echo.personal", live_check=True)
result = await api.validate_deployment(
deployment_id="echo.personal", live_check=True
)
assert result["status"] == "unrunnable"
assert result["diagnostics"][0]["code"] == "source_unreachable"
-1
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
from pathlib import Path
import pytest
-1
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
from pathlib import Path
from typing import Any
+3 -1
View File
@@ -25,7 +25,9 @@ def test_platform_context_uses_identity_for_platform_sources() -> None:
def test_platform_context_rejects_unbound_source() -> None:
context = SourceBindingPlatformContext(source_bindings={}, read_resource_handler=None)
context = SourceBindingPlatformContext(
source_bindings={}, read_resource_handler=None
)
with pytest.raises(KeyError, match="unbound logical source"):
context.resolve_source("drive")
+3 -1
View File
@@ -214,7 +214,9 @@ edges: []
assert payload["source_bindings"] == {"local.ops": "local.ops"}
def test_artifact_create_from_plan_rejects_non_object_yaml(monkeypatch, tmp_path) -> None:
def test_artifact_create_from_plan_rejects_non_object_yaml(
monkeypatch, tmp_path
) -> None:
handlers = _ArtifactHandlers()
monkeypatch.setattr(
"wf_cli.commands.artifacts.load_cli_context",
+17 -9
View File
@@ -77,12 +77,16 @@ class _FakeOAuthClient:
self.auth_kwargs: dict[str, object] = {}
self.fetch_calls: list[str] = []
def create_authorization_url(self, auth_url: str, **kwargs: object) -> tuple[str, str]:
def create_authorization_url(
self, auth_url: str, **kwargs: object
) -> tuple[str, str]:
assert auth_url == "https://accounts.google.com/o/oauth2/v2/auth"
self.auth_kwargs = dict(kwargs)
return self.authorization_url, "state-123"
async def fetch_token(self, token_url: str, authorization_response: str) -> dict[str, object]:
async def fetch_token(
self, token_url: str, authorization_response: str
) -> dict[str, object]:
self.fetch_calls.append(authorization_response)
return {
"refresh_token": "refresh",
@@ -144,7 +148,9 @@ async def test_oauth_code_login_flow_callback_can_supply_response() -> None:
assert client.fetch_calls == ["http://127.0.0.1/callback?code=abc&state=state-123"]
def test_auth_oauth_login_saves_record_from_provider_profile(monkeypatch, tmp_path) -> None:
def test_auth_oauth_login_saves_record_from_provider_profile(
monkeypatch, tmp_path
) -> None:
saved: list[dict[str, object]] = []
class _FakeAdmin:
@@ -178,15 +184,17 @@ def test_auth_oauth_login_saves_record_from_provider_profile(monkeypatch, tmp_pa
"auth_url": "https://accounts.google.com/o/oauth2/v2/auth",
"token_url": "https://oauth2.googleapis.com/token",
"client_id_env": "GOOGLE_OAUTH_CLIENT_ID",
"scopes": ["https://www.googleapis.com/auth/drive.readonly"],
"extra_authorize_params": {
"access_type": "offline",
"prompt": "consent",
},
"scopes": [
"https://www.googleapis.com/auth/drive.readonly"
],
"extra_authorize_params": {
"access_type": "offline",
"prompt": "consent",
},
}
}
}
}
}
),
encoding="utf-8",
)
+4 -4
View File
@@ -170,12 +170,12 @@ def test_wf_config_validate_uses_global_config_when_path_omitted(
payload = json.loads(result.output)
assert payload["valid"] is True
assert payload["path"] == str(config_path)
assert payload["sources"] == [
{"id": "wf.std", "kind": "stdlib", "status": "ok"}
]
assert payload["sources"] == [{"id": "wf.std", "kind": "stdlib", "status": "ok"}]
def test_wf_config_validate_reports_python_source_import_failure(tmp_path: Path) -> None:
def test_wf_config_validate_reports_python_source_import_failure(
tmp_path: Path,
) -> None:
config_path = tmp_path / "wf.config.json"
config_path.write_text(
json.dumps(
+1 -3
View File
@@ -268,9 +268,7 @@ async def test_content_access_uses_stateful_runtime_for_upstream_content() -> No
async def test_read_resource_by_source_uri_reads_upstream() -> None:
service = WfMcpService(
store=FileStore(local_temp_root() / "content_source_uri")
)
service = WfMcpService(store=FileStore(local_temp_root() / "content_source_uri"))
service.register_connection(
ConnectionConfig(id="demo.personal", server="demo", account="personal")
)
@@ -20,7 +20,9 @@ def _connection(**metadata: object) -> ConnectionConfig:
)
def _provider(tmp_path: Path, connection: ConnectionConfig) -> SourceDiagnosticsProvider:
def _provider(
tmp_path: Path, connection: ConnectionConfig
) -> SourceDiagnosticsProvider:
registry = ConnectionRegistry()
registry.register(connection)
return SourceDiagnosticsProvider(
@@ -100,10 +100,12 @@ def test_workflow_runtime_service_prepares_node_registry_and_reducers() -> None:
emit_event=lambda event: None,
)
workflow, registry, reducers, prepared_subgraphs, platform_context = runtime.prepare_workflow_runtime(
single_echo_plan("runtime_prepare", "demo.personal.echo_tool"),
deployment=None,
artifact=None,
workflow, registry, reducers, prepared_subgraphs, platform_context = (
runtime.prepare_workflow_runtime(
single_echo_plan("runtime_prepare", "demo.personal.echo_tool"),
deployment=None,
artifact=None,
)
)
assert "demo.personal.echo_tool" in [nd.name for nd in workflow.node_defs]
@@ -129,7 +129,9 @@ def test_file_auth_store_writes_new_stored_auth_record_shape(tmp_path: Path) ->
assert data["metadata"]["provider"] == "google"
def test_file_auth_store_loads_old_format_through_load_auth_record(tmp_path: Path) -> None:
def test_file_auth_store_loads_old_format_through_load_auth_record(
tmp_path: Path,
) -> None:
store = FileAuthStore(tmp_path)
path = tmp_path / "auth" / "github.work.json"
path.write_text(
+4 -4
View File
@@ -449,7 +449,9 @@ async def test_rpc_client_draft_workspace_focused_edit_methods(tmp_path) -> None
server = build_local_static_workflow_server(tmp_path / "store")
app = create_rpc_app(server)
transport = httpx.ASGITransport(app=app)
async with httpx.AsyncClient(transport=transport, base_url="http://test") as http_client:
async with httpx.AsyncClient(
transport=transport, base_url="http://test"
) as http_client:
client = RpcWorkflowApiClient(
url="http://test/rpc",
timeout_seconds=5,
@@ -503,6 +505,4 @@ async def test_rpc_client_diagnoses_source(tmp_path) -> None:
payload = await Client().diagnose_source(source_id="demo.personal")
assert payload == {"source_id": "demo.personal", "status": "ok"}
assert calls == [
("workflow.sources.diagnose", {"source_id": "demo.personal"})
]
assert calls == [("workflow.sources.diagnose", {"source_id": "demo.personal"})]