Skip to content

Commit 1a3eca3

Browse files
fix: address display name default
1 parent eebbeb2 commit 1a3eca3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

packages/models-library/src/models_library/rpc/notifications/channels/_email_channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class EmailAddress(BaseModel):
7-
display_name: str | None = None
7+
display_name: str = ""
88
addr_spec: EmailStr
99

1010

services/notifications/tests/unit/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from celery.signals import worker_init, worker_shutdown
1515
from celery.worker.worker import WorkController
1616
from celery_library.signals import on_worker_init, on_worker_shutdown
17+
from faker import Faker
1718
from fastapi import FastAPI
1819
from fastapi.testclient import TestClient
1920
from pytest_mock import MockerFixture
@@ -152,3 +153,12 @@ async def notifications_rabbitmq_rpc_client(
152153
@pytest.fixture
153154
def 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+
}

services/notifications/tests/unit/test_send_email_tasks.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
import pytest
24
from faker import Faker
35
from models_library.rpc.notifications import Notification
@@ -28,6 +30,7 @@
2830
)
2931
async 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
),

0 commit comments

Comments
 (0)