Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 35f3732

Browse files
committed
fix: aggiungi mock per il servizio email nel test di registrazione utente
1 parent 70b2ae5 commit 35f3732

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/routes/test_user.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,20 @@ async def delete_user(self, user_id: str):
107107

108108

109109
@pytest.mark.asyncio
110-
async def test__unit_test__register_user(fake_user_repo):
110+
async def test__unit_test__register_user(fake_user_repo, monkeypatch):
111111
user_data = UserCreate(name="Bob", email="hi@hi.com", scopes=AccessRoles.USER)
112+
113+
mock_email_service_instance = AsyncMock()
114+
mock_email_service_instance.send_email = AsyncMock(return_value=None)
115+
116+
class MockEmailService:
117+
def __init__(self):
118+
pass
119+
async def send_email(self, to, subject, body):
120+
return await mock_email_service_instance.send_email(to, subject, body)
121+
122+
monkeypatch.setattr("app.routes.user.EmailService", MockEmailService)
123+
112124
result = await register_user(user_data, current_user, fake_user_repo)
113125
assert result["message"] != None
114126

0 commit comments

Comments
 (0)