File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
packages/models-library/src/models_library/rpc/notifications/channels
services/notifications/tests/unit Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 44
55
66class EmailAddress (BaseModel ):
7- display_name : str | None = None
7+ display_name : str = ""
88 addr_spec : EmailStr
99
1010
Original file line number Diff line number Diff line change 1414from celery .signals import worker_init , worker_shutdown
1515from celery .worker .worker import WorkController
1616from celery_library .signals import on_worker_init , on_worker_shutdown
17+ from faker import Faker
1718from fastapi import FastAPI
1819from fastapi .testclient import TestClient
1920from pytest_mock import MockerFixture
@@ -152,3 +153,12 @@ async def notifications_rabbitmq_rpc_client(
152153@pytest .fixture
153154def test_client (fastapi_app : FastAPI ) -> TestClient :
154155 return TestClient (fastapi_app )
156+
157+
158+ @pytest .fixture
159+ def fake_ipinfo (faker : Faker ) -> dict [str , Any ]:
160+ return {
161+ "x-real-ip" : faker .ipv4 (),
162+ "x-forwarded-for" : faker .ipv4 (),
163+ "peername" : faker .ipv4 (),
164+ }
Original file line number Diff line number Diff line change 1+ from typing import Any
2+
13import pytest
24from faker import Faker
35from models_library .rpc .notifications import Notification
2830)
2931async def test_account_requested (
3032 notifications_rabbitmq_rpc_client : RabbitMQRPCClient ,
33+ fake_ipinfo : dict [str , Any ],
3134 faker : Faker ,
3235):
3336 user_email = faker .email ()
@@ -55,6 +58,7 @@ async def test_account_requested(
5558 ),
5659 ),
5760 host = HttpUrl (faker .url ()),
61+ ipinfo = fake_ipinfo ,
5862 ),
5963 channel = EmailChannel (
6064 from_addr = EmailAddress (addr_spec = faker .email ()),
@@ -103,8 +107,11 @@ async def test_account_approved(
103107 link = HttpUrl (faker .url ()),
104108 ),
105109 channel = EmailChannel (
106- from_addr = EmailAddress (addr_spec = faker .email ()),
110+ from_addr = EmailAddress (
111+ display_name = faker .name (), addr_spec = faker .email ()
112+ ),
107113 to_addr = EmailAddress (
114+ display_name = faker .name (),
108115 addr_spec = user_email ,
109116 ),
110117 ),
You can’t perform that action at this time.
0 commit comments