freeleaps-service-hub/apps/notification/tests/integration_tests
2025-09-22 11:01:34 +08:00
..
create_global_templates.py feat(template): add the new job notification template 2025-09-08 17:10:01 +08:00
local.env feat(cache): add the cache volume 2025-09-22 11:01:34 +08:00
README.md refactor(test): relocate template tests to integration suite 2025-08-20 00:34:33 +08:00
test_email_sender_real.py test(api): test the api interfaces cao work 2025-08-14 21:11:58 +08:00
test_template_message_real.py test(api): test the api interfaces cao work 2025-08-14 21:11:58 +08:00
test_tenant_notification_real.py fix(email_sending): use the template created and stored in mongodb 2025-08-14 21:35:14 +08:00

api-test

# run the command

cd notification
source local.env 
python webapi/main.py &

After running the commands, the notification api will start

create the data of template message and email senders in mongodb

test the interfaces under webapi/routes/template_message.py & email_sender.py

can comment and uncomment some lines in async def run_all_tests(self) to test certain interfaces

# run the command
cd tests/integration_tests
export PYTHONPATH="/yourpath/freeleaps-service-hub/apps/notification
source ../../local.env 
python test_email_sender_real.py 
python test_template_message_real.py

After running the commands, the template message and email sender will stored in the mongodb

Based on the template message and email sender, test the interfaces under webapi/routes/

tenant_notification.py

can comment and uncomment some lines in async def run_all_tests(self) to test certain interfaces

test_recipient_emails can be set as the true email addresses

# run the command
python test_tenant_notification_real.py

After running the commands, email will be sent

Q & A

Q: Why is the email sent twice?

Q: Why do I recieve 2 identical emails at the same time

A: when use local mongodb_uri, use exchange_name_format = "freeleaps.notification.exchange.local.{} in infra/rabbitmq/async_client.py.

while exchange_name_format = "freeleaps.notification.exchange.{}" for alpha mongodb_uri.