Skip to content

Conversation

@PulinduVR
Copy link
Collaborator

Summary

  • This PR contains unit tests added to email_sender.

Checklist

  • Documentation or README updated (if behavior/configuration changed)
  • Tests added or updated as appropriate
  • No breaking changes introduced, or breaking changes clearly documented
  • Database migrations applied (if applicable)
  • Secrets and configuration handled securely (no secrets committed)
  • Formatting, linting, and type checks passed (pre-commit)
  • Tests ran locally and verified

Screenshots

Screenshots of the API documentation (swagger) or other relevant artifacts associated with this PR (if applicable).

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app/core/tests
  test_email_sender.py
  test_storage.py
  app/fixtures
  email_factory.py
Project Total  

This report was generated by python-coverage-comment-action

@PulinduVR PulinduVR marked this pull request as ready for review January 1, 2026 07:29
@PulinduVR PulinduVR changed the title Test/email sender Add unit tests for email sender Jan 2, 2026
Comment on lines 63 to 66
class ConcreteSender(EmailSender):
@override
async def send_email(self, email: Email) -> str:
return await super().send_email(email) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove concrete sender and use the base sender

Comment on lines 15 to 34
@pytest.fixture
def email_factory(email_templates: tuple[Path, Path]):
html_template, text_template = email_templates

def _create_email(
sender: str = "test@testmail.com",
receivers: list[EmailStr] | None = None,
subject: str = "Test",
template_data: dict[str, object] | None = None,
):
return Email(
sender=sender,
receivers=receivers or ["receiver@testemail.com"],
subject=subject,
body_html_template=html_template,
body_text_template=text_template,
template_data=template_data or {"name": "TestUser"},
)

return _create_email
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use factory-boy library
Or try to use email_fixture directly
If using this fixture, rename to email_factory_fixture



def test_get_email_sender_raises_not_implemented_error_for_invalid_email_sender_types(settings_fixture: SettingsDep):
settings_fixture.email_sender_type = "invalid" # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrow the type ignore to the specific type check

app/conftest.py Outdated
Comment on lines 194 to 210
@pytest.fixture
def email_templates(tmp_path: Path) -> tuple[Path, Path]:
html_template = tmp_path / "test.mjml"
text_template = tmp_path / "test.txt"

_ = html_template.write_text("""
<mjml>
<mj-body>
<mj-text>Hello {{ name}}</mj-text>
</mj-body>
</mjml>
""")

_ = text_template.write_text("Hello {{ name }}")

return html_template, text_template

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to test_email_sender file

app/conftest.py Outdated
Comment on lines 212 to 214
@pytest.fixture
def fake_settings(settings_fixture: Settings) -> Settings:
return settings_fixture
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

@kdsuneraavinash kdsuneraavinash merged commit 4955833 into master Jan 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants