Skip to content

test: migrate app service tests to testcontainers#34025

Merged
asukaminato0721 merged 5 commits intolanggenius:mainfrom
Desel72:test/migrate-app-service-tests-to-testcontainers
Mar 25, 2026
Merged

test: migrate app service tests to testcontainers#34025
asukaminato0721 merged 5 commits intolanggenius:mainfrom
Desel72:test/migrate-app-service-tests-to-testcontainers

Conversation

@Desel72
Copy link
Copy Markdown
Contributor

@Desel72 Desel72 commented Mar 24, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

  • Migrate remaining mock-based app service tests from
    api/tests/unit_tests/services/test_app_service.py (609 lines, 19 tests) into
    the existing testcontainers integration test at
    api/tests/test_containers_integration_tests/services/test_app_service.py
    (1144 lines, 19 tests).

  • The existing testcontainers file covered app CRUD, pagination, update operations,
    deletion, app meta, and code lookups. This PR adds 5 new integration tests for
    error paths: code/ID lookup not-found errors, empty metadata when workflow/config
    missing, and None return for empty tag filter. Then removes the fully superseded
    609-line mock-based file.

Part of #32454

Screenshots

Before After
... ...

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. (This doesn't apply to typos!)
  • 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 24, 2026
@asukaminato0721
Copy link
Copy Markdown
Contributor

fix conflicts

@Desel72 Desel72 force-pushed the test/migrate-app-service-tests-to-testcontainers branch from e3ca5d3 to 297d6c2 Compare March 24, 2026 14:10
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-24 14:11:20.616061900 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-24 14:11:10.318027340 +0000
@@ -1144,6 +1144,20 @@
     --> tests/test_containers_integration_tests/services/test_app_service.py:1236:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
     --> tests/test_containers_integration_tests/services/test_app_service.py:1244:68
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1280:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1294:41
+ERROR Object of class `TestAppService` has no attribute `_create_test_app_and_account` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1303:27
+ERROR Object of class `TestAppService` has no attribute `_create_test_app_and_account` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1317:27
+ERROR Could not find name `AppService` [unknown-name]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1320:23
+ERROR Object of class `TestAppService` has no attribute `_create_test_app_and_account` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1356:27
+ERROR Could not find name `AppService` [unknown-name]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1359:23
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_conversation_service.py:43:18
 ERROR Object of class `NoneType` has no attribute `quota_used` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-24 15:12:00.563491186 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-24 15:11:49.186578305 +0000
@@ -1014,6 +1014,16 @@
     --> tests/test_containers_integration_tests/services/test_app_service.py:1236:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
     --> tests/test_containers_integration_tests/services/test_app_service.py:1244:68
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1280:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1294:41
+ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1311:61
+ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1329:13
+ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1373:13
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_conversation_service.py:43:18
 ERROR Object of class `NoneType` has no attribute `quota_used` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-24 15:27:56.748514645 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-24 15:27:44.995508780 +0000
@@ -1014,6 +1014,10 @@
     --> tests/test_containers_integration_tests/services/test_app_service.py:1236:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
     --> tests/test_containers_integration_tests/services/test_app_service.py:1244:68
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1280:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1294:41
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_conversation_service.py:43:18
 ERROR Object of class `NoneType` has no attribute `quota_used` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-24 15:40:06.424336785 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-24 15:39:55.864402595 +0000
@@ -1014,6 +1014,10 @@
     --> tests/test_containers_integration_tests/services/test_app_service.py:1236:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
     --> tests/test_containers_integration_tests/services/test_app_service.py:1244:68
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1280:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1294:41
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_conversation_service.py:43:18
 ERROR Object of class `NoneType` has no attribute `quota_used` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-24 15:48:31.042832607 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-24 15:48:20.125878509 +0000
@@ -1014,6 +1014,10 @@
     --> tests/test_containers_integration_tests/services/test_app_service.py:1236:68
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
     --> tests/test_containers_integration_tests/services/test_app_service.py:1244:68
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1280:41
+ERROR Argument `SimpleNamespace` is not assignable to parameter `app_model` with type `App` in function `services.app_service.AppService.get_app_meta` [bad-argument-type]
+    --> tests/test_containers_integration_tests/services/test_app_service.py:1294:41
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_conversation_service.py:43:18
 ERROR Object of class `NoneType` has no attribute `quota_used` [missing-attribute]

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 25, 2026
@asukaminato0721 asukaminato0721 merged commit 81a2eba into langgenius:main Mar 25, 2026
14 checks passed
@asukaminato0721
Copy link
Copy Markdown
Contributor

@Desel72 Desel72 deleted the test/migrate-app-service-tests-to-testcontainers branch March 25, 2026 04:08
CodingOnStar pushed a commit that referenced this pull request Mar 25, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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