Livia-1212 / event_manager

MIT License
0 stars 0 forks source link

Email Service Issues #4

Closed Livia-1212 closed 4 hours ago

Livia-1212 commented 1 day ago

Tests related to the email service fail due to SMTP server connection issues, resulting in smtplib.SMTPServerDisconnected: Connection unexpectedly closed.

Affected Tests: test_send_markdown_email test_create_user_with_valid_data test_register_user_with_valid_data

Suggested Fix:

1.Verify SMTP configuration in the .env or settings file (e.g., smtp_server, smtp_username, smtp_password). 2.Ensure the SMTP server is accessible and properly configured for testing purposes. For tests, consider mocking the SMTP client to avoid actual server dependency.

  1. Created an email account on Mailtrap.io, use sandbox.smtp.mailtrap.io as the smtp_server on .env file, use the sandbox username and password and loaded environment variables from .env file
Livia-1212 commented 1 day ago

updated email_service.py

Livia-1212 commented 18 hours ago

Steps Performed: Used the nc (Netcat) command to test the connectivity to the SMTP server (smtp.mailtrap.io) on port 2525: nc -vz smtp.mailtrap.io 2525

Result: Connection to smtp.mailtrap.io port 2525 [tcp/ms-v-worlds] succeeded!

This indicates that: The server is reachable from the current environment. Port 2525 is open and accepting connections.

Next Steps:

  1. Verify SMTP Configuration in the Application
  2. Test Email Sending Locally
  3. Check Error Logs
  4. Mock the Email Service in Tests
  5. Enable Debug Logging (Optional)
Livia-1212 commented 14 hours ago

The issue was marked as completed in #6 accidentally.

Current remaining issues: tests/test_email.py::test_send_markdown_email - smtplib.SMTPServerDisconnected: Connection unexpectedly closed

Livia-1212 commented 6 hours ago

New issue: there is no user_base_data_invalid fixture

Fix: Added fixture user_base_data_invalid that returns the "email": "john.doe.example.com" inside conftest.py. This will ensure that the test passes test_user_base_invalid_email in test_user_schemas.py