Skip to content

Commit 906c67f

Browse files
tests: add new test
1 parent 5d9fc5c commit 906c67f

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

services/notifications/tests/unit/test_send_email_tasks.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
from models_library.rpc.notifications import Notification
44
from models_library.rpc.notifications.channels import EmailAddress, EmailChannel
55
from models_library.rpc.notifications.events import (
6+
AccountApprovedEvent,
67
AccountRequestedEvent,
78
ProductData,
89
ProductUIData,
910
UserData,
1011
)
12+
from pydantic import HttpUrl
1113
from servicelib.rabbitmq import RabbitMQRPCClient
1214
from servicelib.rabbitmq.rpc_interfaces.notifications import (
1315
send_notification,
@@ -52,7 +54,53 @@ async def test_account_requested(
5254
strong_color=faker.color_name(),
5355
),
5456
),
55-
host=faker.url(),
57+
host=HttpUrl(faker.url()),
58+
),
59+
channel=EmailChannel(
60+
from_addr=EmailAddress(addr_spec=faker.email()),
61+
to_addr=EmailAddress(
62+
addr_spec=user_email,
63+
),
64+
),
65+
),
66+
)
67+
68+
# TODO: wait for the email to be sent and check
69+
70+
71+
@pytest.mark.usefixtures(
72+
"mock_celery_worker",
73+
"mock_fastapi_app",
74+
)
75+
async def test_account_approved(
76+
notifications_rabbitmq_rpc_client: RabbitMQRPCClient,
77+
faker: Faker,
78+
):
79+
user_email = faker.email()
80+
81+
await send_notification(
82+
notifications_rabbitmq_rpc_client,
83+
notification=Notification(
84+
event=AccountApprovedEvent(
85+
user=UserData(
86+
username=faker.user_name(),
87+
first_name=faker.first_name(),
88+
last_name=faker.last_name(),
89+
email=user_email,
90+
),
91+
product=ProductData(
92+
product_name=faker.company(),
93+
display_name=faker.company(),
94+
vendor_display_inline=faker.company_suffix(),
95+
support_email=faker.email(),
96+
homepage_url=faker.url(),
97+
ui=ProductUIData(
98+
project_alias=faker.word(),
99+
logo_url=faker.image_url(),
100+
strong_color=faker.color(),
101+
),
102+
),
103+
link=HttpUrl(faker.url()),
56104
),
57105
channel=EmailChannel(
58106
from_addr=EmailAddress(addr_spec=faker.email()),

0 commit comments

Comments
 (0)