Skip to content

armgit / dify

Public Imported from GitHub
0

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.

test: [Refactor/Chore] use Testcontainers to do sql test #32454 (#32460)

Asuka Minatof38e8cca5210
diff --git a/api/tests/test_containers_integration_tests/models/test_app_model_config.py b/api/tests/test_containers_integration_tests/models/test_app_model_config.py
new file mode 100644
index 00000000000..e8b36097e14
--- /dev/null
+++ b/api/tests/test_containers_integration_tests/models/test_app_model_config.py
@@ -0,0 +1,32 @@
+"""
+Integration tests for AppModelConfig using testcontainers.
+
+These tests validate database-backed model behavior without mocking SQLAlchemy queries.
+"""
+
+from uuid import uuid4
+
+from sqlalchemy.orm import Session
+
+from models.model import AppModelConfig
+
+
+class TestAppModelConfig:
+ """Integration tests for AppModelConfig."""
+
+ def test_annotation_reply_dict_disabled_without_setting(self, db_session_with_containers: Session) -> None:
+ """Return disabled annotation reply dict when no AppAnnotationSetting exists."""
+ # Arrange
+ config = AppModelConfig(app_id=str(uuid4()))
+ db_session_with_containers.add(config)
+ db_session_with_containers.commit()
+
+ # Act
+ result = config.annotation_reply_dict
+
+ # Assert
+ assert result == {"enabled": False}
+
+ # Cleanup
+ db_session_with_containers.delete(config)
+ db_session_with_containers.commit()