|
3 | 3 | from models_library.rpc.notifications import Notification |
4 | 4 | from models_library.rpc.notifications.channels import EmailAddress, EmailChannel |
5 | 5 | from models_library.rpc.notifications.events import ( |
| 6 | + AccountApprovedEvent, |
6 | 7 | AccountRequestedEvent, |
7 | 8 | ProductData, |
8 | 9 | ProductUIData, |
9 | 10 | UserData, |
10 | 11 | ) |
| 12 | +from pydantic import HttpUrl |
11 | 13 | from servicelib.rabbitmq import RabbitMQRPCClient |
12 | 14 | from servicelib.rabbitmq.rpc_interfaces.notifications import ( |
13 | 15 | send_notification, |
@@ -52,7 +54,53 @@ async def test_account_requested( |
52 | 54 | strong_color=faker.color_name(), |
53 | 55 | ), |
54 | 56 | ), |
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()), |
56 | 104 | ), |
57 | 105 | channel=EmailChannel( |
58 | 106 | from_addr=EmailAddress(addr_spec=faker.email()), |
|
0 commit comments