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: migrate web forgot password controller tests to testcontainers (#34288)

YBoycc89b57c1f53
diff --git a/api/tests/unit_tests/controllers/web/test_web_forgot_password.py b/api/tests/test_containers_integration_tests/controllers/web/test_web_forgot_password.py
similarity index 95%
rename from api/tests/unit_tests/controllers/web/test_web_forgot_password.py
rename to api/tests/test_containers_integration_tests/controllers/web/test_web_forgot_password.py
index 3d7c3199476..19057726c34 100644
--- a/api/tests/unit_tests/controllers/web/test_web_forgot_password.py
+++ b/api/tests/test_containers_integration_tests/controllers/web/test_web_forgot_password.py
@@ -1,9 +1,12 @@
+"""Testcontainers integration tests for controllers.web.forgot_password endpoints."""
+
+from __future__ import annotations
+
import base64
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import pytest
-from flask import Flask
from controllers.web.forgot_password import (
ForgotPasswordCheckApi,
@@ -12,13 +15,6 @@ from controllers.web.forgot_password import (
)
-def app():
- flask_app = Flask(__name__)
- flask_app.config["TESTING"] = True
- return flask_app
-
-
@pytest.fixture(autouse=True)
def _patch_wraps():
wraps_features = SimpleNamespace(enable_email_password_login=True)
@@ -33,6 +29,10 @@ def _patch_wraps():
class TestForgotPasswordSendEmailApi:
+ @pytest.fixture
+ def app(self, flask_app_with_containers):
+ return flask_app_with_containers
+
@patch("controllers.web.forgot_password.AccountService.send_reset_password_email")
@patch("controllers.web.forgot_password.AccountService.get_account_by_email_with_case_fallback")
@patch("controllers.web.forgot_password.AccountService.is_email_send_ip_limit", return_value=False)
@@ -69,6 +69,10 @@ class TestForgotPasswordSendEmailApi:
class TestForgotPasswordCheckApi:
+ @pytest.fixture
+ def app(self, flask_app_with_containers):
+ return flask_app_with_containers
+
@patch("controllers.web.forgot_password.AccountService.reset_forgot_password_error_rate_limit")
@patch("controllers.web.forgot_password.AccountService.generate_reset_password_token")
@patch("controllers.web.forgot_password.AccountService.revoke_reset_password_token")
@@ -143,6 +147,10 @@ class TestForgotPasswordCheckApi:
class TestForgotPasswordResetApi:
+ @pytest.fixture
+ def app(self, flask_app_with_containers):
+ return flask_app_with_containers
+
@patch("controllers.web.forgot_password.ForgotPasswordResetApi._update_existing_account")
@patch("controllers.web.forgot_password.AccountService.get_account_by_email_with_case_fallback")
@patch("controllers.web.forgot_password.Session")