Skip to content

test: migrate workflow service tests to testcontainers#34206

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:test/migrate-workflow-service-tests-to-testcontainers
Mar 29, 2026
Merged

test: migrate workflow service tests to testcontainers#34206
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:test/migrate-workflow-service-tests-to-testcontainers

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Mar 27, 2026

Summary

Migrate SQL-related tests from api/tests/unit_tests/services/workflow/test_workflow_service.py to testcontainers integration tests at api/tests/test_containers_integration_tests/services/test_workflow_service.py.

Added 4 missing get_all_published_workflow tests (no_workflow_id, basic, combined_filters, empty_result) using real database queries. Removed the unit test file — the TC file already covered pagination, user_filter, and named_only_filter. The remaining 5 unit tests (submit_human_input_form_preview and run_draft_workflow_node) were pure orchestration tests with fully mocked DB/Session/internals and did not exercise any SQL paths.

Part of #32454

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-27 16:34:21.426381154 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-27 16:34:10.176372380 +0000
@@ -1303,11 +1303,11 @@
 ERROR Argument `Literal['succeeded']` is not assignable to parameter `value` with type `SQLCoreOperations[WorkflowNodeExecutionStatus] | WorkflowNodeExecutionStatus` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_workflow_service.py:173:33
 ERROR Argument `Literal['invalid_mode']` is not assignable to parameter `value` with type `AppMode | SQLCoreOperations[AppMode]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1174:20
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1292:20
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[StatementError]]) [no-matching-overload]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1179:27
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1297:27
 ERROR Argument `dict[str, Any]` is not assignable to parameter `metadata` with type `Mapping[WorkflowNodeExecutionMetadataKey, Any]` in function `graphon.node_events.base.NodeRunResult.__init__` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1523:26
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1641:26
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_workspace_service.py:51:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -7449,14 +7449,6 @@
   --> tests/unit_tests/services/workflow/test_workflow_restore.py:62:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_restore.apply_published_workflow_snapshot_to_draft` [bad-argument-type]
   --> tests/unit_tests/services/workflow/test_workflow_restore.py:70:17
-ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:235:23
-ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:236:21
-ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:291:27
-ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:292:25
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
   --> tests/unit_tests/tasks/test_dataset_indexing_task.py:62:5
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]

@asukaminato0721
Copy link
Copy Markdown
Contributor

resolve conflict

@YB0y YB0y force-pushed the test/migrate-workflow-service-tests-to-testcontainers branch from 6a40241 to 9fe3391 Compare March 27, 2026 23:55
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-27 23:56:25.323481136 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-27 23:56:14.893394088 +0000
@@ -1301,11 +1301,11 @@
 ERROR Argument `Literal['succeeded']` is not assignable to parameter `value` with type `SQLCoreOperations[WorkflowNodeExecutionStatus] | WorkflowNodeExecutionStatus` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_workflow_service.py:173:33
 ERROR Argument `Literal['invalid_mode']` is not assignable to parameter `value` with type `AppMode | SQLCoreOperations[AppMode]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1174:20
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1292:20
 ERROR No matching overload found for function `_pytest.raises.raises` called with arguments: (tuple[type[ValueError], type[StatementError]]) [no-matching-overload]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1179:27
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1297:27
 ERROR Argument `dict[str, Any]` is not assignable to parameter `metadata` with type `Mapping[WorkflowNodeExecutionMetadataKey, Any]` in function `graphon.node_events.base.NodeRunResult.__init__` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1523:26
+    --> tests/test_containers_integration_tests/services/test_workflow_service.py:1641:26
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_workspace_service.py:51:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -7093,14 +7093,6 @@
   --> tests/unit_tests/services/workflow/test_workflow_restore.py:62:18
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_restore.apply_published_workflow_snapshot_to_draft` [bad-argument-type]
   --> tests/unit_tests/services/workflow/test_workflow_restore.py:70:17
-ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:235:23
-ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:236:21
-ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:291:27
-ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.workflow_service.WorkflowService.submit_human_input_form_preview` [bad-argument-type]
-   --> tests/unit_tests/services/workflow/test_workflow_service.py:292:25
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
   --> tests/unit_tests/tasks/test_dataset_indexing_task.py:62:5
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 29, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Mar 29, 2026
Merged via the queue into langgenius:main with commit b36b077 Mar 29, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants