freeleaps-service-hub/apps/notification/tests/integration_tests/README.md

43 lines
1.5 KiB
Markdown

## api-test
```shell
# run the command
cd notification
# for local environment
source local.env
python webapi/main.py &
# for alpha environment
source alpha.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
```shell
# 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
```shell
# 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: in infra/rabbitmq/async_client.py, use exchange_name_format = "freeleaps.notification.exchange.local.{}" for local environment, while exchange_name_format = "freeleaps.notification.exchange.{}" for alpha environment.