Skip to content

test: migrate workspace wraps controller tests to testcontainers#34296

Merged
asukaminato0721 merged 4 commits intolanggenius:mainfrom
YB0y:test/migrate-workspace-wraps-controller-tests-to-testcontainers
Mar 30, 2026
Merged

test: migrate workspace wraps controller tests to testcontainers#34296
asukaminato0721 merged 4 commits intolanggenius:mainfrom
YB0y:test/migrate-workspace-wraps-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/workspace/test_workspace_wraps.py to testcontainers integration tests at api/tests/test_containers_integration_tests/controllers/console/workspace/test_workspace_wraps.py.

Moved the file as-is : tests already use from __future__ import annotations and don't depend on Flask(__name__). All 7 tests migrated: plugin_permission_required decorator tests covering install permission (nobody forbidden, admin requires admin, admin allows admin), debug permission (nobody forbidden, admin requires admin), and no-permission passthrough. Session and db remain monkeypatched as tests verify decorator permission 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:XS This PR changes 0-9 lines, ignoring generated files. label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@asukaminato0721
Copy link
Copy Markdown
Contributor

Since it's container, I prefer don't mock the db

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-30 15:04:44.648223521 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-30 15:04:33.830053488 +0000
@@ -669,6 +669,8 @@
 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/helpers.py:40:48
 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/workspace/test_workspace_wraps.py:18:48
+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/core/app/layers/test_pause_state_persist_layer.py:95:20
 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/core/app/layers/test_pause_state_persist_layer.py:104:20

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-30 15:06:43.721772585 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-30 15:06:32.965746019 +0000
@@ -669,6 +669,8 @@
 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/helpers.py:40:48
 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/workspace/test_workspace_wraps.py:17:48
+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/core/app/layers/test_pause_state_persist_layer.py:95:20
 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/core/app/layers/test_pause_state_persist_layer.py:104:20

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the plugin_permission_required decorator tests for the console workspace controller from unit tests to the testcontainers-based integration test suite, aligning with the ongoing effort to reduce heavy DB patching and exercise real database behavior.

Changes:

  • Removed the unit test module for workspace permission wrapping.
  • Added a new testcontainers integration test module validating plugin_permission_required against a real DB session/engine.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
api/tests/unit_tests/controllers/console/workspace/test_workspace_wraps.py Removed the previous unit-test-based coverage for plugin_permission_required.
api/tests/test_containers_integration_tests/controllers/console/workspace/test_workspace_wraps.py Reintroduced the decorator tests under the testcontainers integration test suite, creating real Tenant / TenantPluginPermission records.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

auto-merge was automatically disabled March 30, 2026 15:48

Head branch was pushed to by a user without write access

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@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 953bcc3 Mar 30, 2026
27 checks passed
@YB0y YB0y deleted the test/migrate-workspace-wraps-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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants