Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
test(api): bring service test modules under strict pyrefly (#45327)
Felix Shi5c9efb8e5b72
diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex 634f8366f81..a1bf59b073b 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -42,7 +42,6 @@ project-excludes = ["controllers/console/datasets/test_metadata.py","controllers/console/snippets/test_snippet_workflow.py","controllers/console/tag/test_tags.py",- "services/knowledge/test_dataset_read_service.py","controllers/console/test_files.py","controllers/console/test_human_input_form.py","controllers/console/test_wraps.py",@@ -298,7 +297,6 @@ project-excludes = ["models/test_workflow.py","services/agent/test_dsl_service.py","services/agent/test_roster_service.py",- "services/agent/test_workflow_publish_service.py","../helpers/unit/services/controller_api.py","services/data_migration/test_export_service.py","services/data_migration/test_import_service.py",@@ -330,9 +328,7 @@ project-excludes = ["services/test_file_service.py","services/test_human_input_delivery_test_service.py","services/test_knowledge_retrieval_inner_service.py",- "services/knowledge/metadata/test_application.py","services/model_provider/test_service.py",- "services/test_operation_service.py","services/trigger/test_schedule_service.py","services/test_snippet_dsl_service.py","services/test_snippet_generate_service.py",diff --git a/api/tests/unit_tests/services/agent/test_workflow_publish_service.py b/api/tests/unit_tests/services/agent/test_workflow_publish_service.pyindex 1aa7b13e25f..58365adc37f 100644--- a/api/tests/unit_tests/services/agent/test_workflow_publish_service.py+++ b/api/tests/unit_tests/services/agent/test_workflow_publish_service.py@@ -558,7 +558,7 @@ def test_restore_clones_inline_binding_owned_by_published_workflow(assert restored.current_snapshot_id == "draft-snapshot"-def test_output_routes_round_trip_through_sync_projection_and_publication(sqlite_session: Session):+def test_output_routes_round_trip_through_sync_projection_and_publication(sqlite_session: Session) -> None:import jsonfrom models.agent_config_entities import WorkflowNodeJobConfig@@ -598,6 +598,7 @@ def test_output_routes_round_trip_through_sync_projection_and_publication(sqlitefrozen = sqlite_session.scalar(select(WorkflowAgentNodeBinding).where(WorkflowAgentNodeBinding.workflow_id == published.id))+ assert frozen is not Noneassert WorkflowNodeJobConfig.model_validate(frozen.node_job_config_dict).output_routes.model_dump() == routesnode_data["agent_output_routes"] = {"enabled": False, "routes": routes["routes"]}workflow.graph = json.dumps({"nodes": [{"id": "route-node", "data": node_data}], "edges": []})diff --git a/api/tests/unit_tests/services/knowledge/metadata/test_application.py b/api/tests/unit_tests/services/knowledge/metadata/test_application.pyindex fad7ddecd81..f74fd5b1e6b 100644--- a/api/tests/unit_tests/services/knowledge/metadata/test_application.py+++ b/api/tests/unit_tests/services/knowledge/metadata/test_application.py@@ -1,4 +1,3 @@-from collections.abc import Iteratorfrom datetime import datetimefrom pathlib import Pathfrom typing import cast@@ -10,7 +9,7 @@ from sqlalchemy.orm import Session, sessionmakerfrom models import Account, Tenantfrom models.dataset import DatasetMetadataBinding, Document-from models.enums import DocumentCreatedFrom+from models.enums import DocumentCreatedFrom, IndexingStatusfrom repositories.knowledge.metadata_repository import SQLAlchemyMetadataRepositoryfrom services.errors.metadata import MetadataResourceNotFoundErrorfrom services.knowledge.dataset_access import DatasetAccess@@ -296,7 +295,7 @@ def _operation(document_id: str, metadata_id: str, *, partial: bool = False) ->class TestMetadataServiceSessionBoundaryCases:@staticmethod@pytest.fixture- def metadata_service(sqlite_session_factory: sessionmaker[Session]) -> Iterator[MetadataService]:+ def metadata_service(sqlite_session_factory: sessionmaker[Session]) -> MetadataService:with sqlite_session_factory.begin() as session:account = make_account(account_id="actor", name="User", email="[email protected]")session.add(account)@@ -316,7 +315,7 @@ class TestMetadataServiceSessionBoundaryCases:)document.enabled = Truedocument.archived = False- document.indexing_status = "completed"+ document.indexing_status = IndexingStatus.COMPLETEDsession.add(document)return MetadataService(store=SQLAlchemyMetadataRepository(session_factory=sqlite_session_factory),@@ -431,6 +430,7 @@ class TestMetadataServiceSessionBoundaryCases:foreign = session.get(Document, FOREIGN_ID)assert document is not Noneassert foreign is not None+ assert document.doc_metadata is not Noneassert document.doc_metadata["uploader"] == "User"assert foreign.doc_metadata is Nonemetadata_service.disable_built_in_field(REF)diff --git a/api/tests/unit_tests/services/knowledge/test_dataset_read_service.py b/api/tests/unit_tests/services/knowledge/test_dataset_read_service.pyindex 37f9e6364c8..2a2c9715e3a 100644--- a/api/tests/unit_tests/services/knowledge/test_dataset_read_service.py+++ b/api/tests/unit_tests/services/knowledge/test_dataset_read_service.py@@ -91,7 +91,7 @@ def make_document(*, data_source_type: str, data_source_info: str) -> Document:class TestDocumentDetailDataSourceInfo:"""Test cases for document detail API data_source_info serialization."""- def test_data_source_info_dict_returns_raw_data(self):+ def test_data_source_info_dict_returns_raw_data(self) -> None:"""Test that data_source_info_dict returns raw JSON data for all data_source_type values."""# Test data for different data_source_type valuesfor case in cases:@@ -107,7 +107,7 @@ class TestDocumentDetailDataSourceInfo:# Verify raw_result is always a valid dictassert isinstance(raw_result, dict)- def test_local_file_data_source_info_without_db_context(self):+ def test_local_file_data_source_info_without_db_context(self) -> None:"""Test that local_file type data_source_info_dict works without database context."""test_data: LocalFileInfo = {"file_path": "/local/path/document.txt",@@ -129,7 +129,7 @@ class TestDocumentDetailDataSourceInfo:assert "file_path" in raw_dataassert "size" in raw_data- def test_notion_and_website_crawl_data_source_detail(self):+ def test_notion_and_website_crawl_data_source_detail(self) -> None:"""Test that notion_import and website_crawl return raw data in data_source_detail_dict."""# Test notion_importnotion_data: NotionImportInfo = {"notion_page_id": "page-123", "workspace_id": "ws-456"}@@ -153,7 +153,7 @@ class TestDocumentDetailDataSourceInfo:detail_result = get_document_source_detail(document, session=MagicMock())assert detail_result == website_data- def test_local_file_data_source_detail_dict_without_db(self):+ def test_local_file_data_source_detail_dict_without_db(self) -> None:"""Test that local_file returns empty data_source_detail_dict (this doesn't need DB context)."""# Test local_file - this should work without database context since it returns {} earlydocument = make_document(