From cc89b57c1f53361778af356be77334ccdbb38eb6 Mon Sep 17 00:00:00 2001 From: YBoy Date: Mon, 30 Mar 2026 18:01:50 +0300 Subject: [PATCH] test: migrate web forgot password controller tests to testcontainers (#34288) --- .../web/test_web_forgot_password.py | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) rename api/tests/{unit_tests => test_containers_integration_tests}/controllers/web/test_web_forgot_password.py (95%) 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 ( ) -@pytest.fixture -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")