Skip to content

test: migrate app apis controller tests to testcontainers#34291

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:test/migrate-app-apis-controller-tests-to-testcontainers
Mar 30, 2026
Merged

test: migrate app apis controller tests to testcontainers#34291
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:test/migrate-app-apis-controller-tests-to-testcontainers

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Mar 30, 2026

Summary

Migrate tests from api/tests/unit_tests/controllers/console/app/test_app_apis.py to testcontainers integration tests at api/tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py.

Replaced Flask(__name__) with flask_app_with_containers fixture across all test classes that use request context. All 30 tests migrated covering: completion endpoints (payload validation, success/error paths), app endpoints (icon type preservation, payload validation), ops trace endpoints (get/post/delete), site endpoints (update/token reset), workflow endpoints (payload, app log, draft variable, statistics, triggers), MCP server payloads, error handling, and payload integration tests. Service calls remain mocked as tests verify controller routing and response mapping logic.

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:M This PR changes 30-99 lines, ignoring generated files. label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-30 14:27:17.927766448 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-30 14:27:07.052742361 +0000
@@ -660,6 +660,8 @@
   --> tests/integration_tests/workflow/nodes/test_tool.py:65:16
 ERROR `dict[str, str | None]` is not assignable to attribute `env` with type `dict[str, str]` [bad-assignment]
    --> tests/test_containers_integration_tests/conftest.py:207:39
+ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
+   --> tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py:579:51
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/app/test_chat_conversation_status_count_api.py:33:48
 ERROR Object of class `RequestError` has no attribute `response` [missing-attribute]
@@ -1768,8 +1770,6 @@
    --> tests/unit_tests/controllers/console/app/test_annotation_security.py:242:78
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
    --> tests/unit_tests/controllers/console/app/test_annotation_security.py:262:35
-ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
-   --> tests/unit_tests/controllers/console/app/test_app_apis.py:612:51
 ERROR Object of class `ModuleType` has no attribute `console_ns` [missing-attribute]
   --> tests/unit_tests/controllers/console/app/test_app_response_models.py:70:5
 ERROR Object of class `ModuleType` has no attribute `api` [missing-attribute]

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Mar 30, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Mar 30, 2026
Merged via the queue into langgenius:main with commit 623c8ae Mar 30, 2026
27 checks passed
@YB0y YB0y deleted the test/migrate-app-apis-controller-tests-to-testcontainers branch April 1, 2026 17:23
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants