simple-module-mail 0.0.43__tar.gz → 0.0.44__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/PKG-INFO +3 -3
- simple_module_mail-0.0.44/mail/constants.py +11 -0
- simple_module_mail-0.0.44/mail/core/__init__.py +1 -0
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/core}/data_compatibility.py +1 -1
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/core}/settings.py +1 -1
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/core}/state.py +1 -1
- simple_module_mail-0.0.44/mail/delivery/__init__.py +1 -0
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/delivery}/runtime.py +5 -5
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/delivery}/sender.py +2 -2
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/mail/module.py +8 -8
- simple_module_mail-0.0.44/mail/settings.py +11 -0
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/pyproject.toml +3 -3
- {simple_module_mail-0.0.43/tests → simple_module_mail-0.0.44/tests/core/module}/test_mail_lifecycle.py +4 -4
- {simple_module_mail-0.0.43/tests → simple_module_mail-0.0.44/tests/core/settings}/test_mail_settings_migration.py +1 -1
- {simple_module_mail-0.0.43/tests → simple_module_mail-0.0.44/tests/delivery/runtime}/test_mail_health.py +3 -3
- {simple_module_mail-0.0.43/tests → simple_module_mail-0.0.44/tests/delivery/sender}/test_mail_sender.py +8 -8
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/.gitignore +0 -0
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/LICENSE +0 -0
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/README.md +0 -0
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/mail/__init__.py +0 -0
- {simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/core}/constants.py +0 -0
- {simple_module_mail-0.0.43 → simple_module_mail-0.0.44}/mail/py.typed +0 -0
- {simple_module_mail-0.0.43/tests → simple_module_mail-0.0.44/tests/core/data_compatibility}/test_mail_data_compatibility.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_mail
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44
|
|
4
4
|
Summary: Outgoing mail (SMTP or console) for simple_module apps, configured from the DB-backed settings
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -12,8 +12,8 @@ License-File: LICENSE
|
|
|
12
12
|
Keywords: email,mail,simple-module,smtp
|
|
13
13
|
Requires-Python: >=3.12
|
|
14
14
|
Requires-Dist: aiosmtplib<6,>=3.0
|
|
15
|
-
Requires-Dist: simple-module-core==0.0.
|
|
16
|
-
Requires-Dist: simple-module-settings==0.0.
|
|
15
|
+
Requires-Dist: simple-module-core==0.0.44
|
|
16
|
+
Requires-Dist: simple-module-settings==0.0.44
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
19
|
# simple_module_mail
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`mail.core.constants`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("mail.constants", remove_in="0.0.46", use="mail.core.constants")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("mail.core.constants")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""What every mail feature builds on: constants, settings, app state, upgrade checks."""
|
{simple_module_mail-0.0.43/mail → simple_module_mail-0.0.44/mail/core}/data_compatibility.py
RENAMED
|
@@ -10,7 +10,7 @@ from simple_module_db.stored_settings import (
|
|
|
10
10
|
from sqlalchemy import select
|
|
11
11
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
12
12
|
|
|
13
|
-
from mail.constants import LEGACY_MAIL_KEYS, UPGRADE_SETTINGS_NAMESPACE
|
|
13
|
+
from mail.core.constants import LEGACY_MAIL_KEYS, UPGRADE_SETTINGS_NAMESPACE
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
async def check_data_compatibility(db: AsyncSession) -> list[DataCompatibilityIssue]:
|
|
@@ -12,7 +12,7 @@ from pydantic import Field
|
|
|
12
12
|
from pydantic_settings import SettingsConfigDict
|
|
13
13
|
from simple_module_core.settings_base import DbBackedSettings
|
|
14
14
|
|
|
15
|
-
from mail import constants as c
|
|
15
|
+
from mail.core import constants as c
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class MailSettings(DbBackedSettings):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Sending mail: the SMTP/console senders and the app-free resolver and health check."""
|
|
@@ -5,16 +5,16 @@ from __future__ import annotations
|
|
|
5
5
|
import os
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
|
-
from settings.service import SettingService
|
|
9
|
-
from settings.store import SettingsStore
|
|
8
|
+
from settings.core.service import SettingService
|
|
9
|
+
from settings.module_settings.store import SettingsStore
|
|
10
10
|
from simple_module_core.environments import NON_PROD_ENVIRONMENTS
|
|
11
11
|
from simple_module_core.health import HealthCheckResult, HealthStatus
|
|
12
12
|
from simple_module_core.mail import MailSender, current_mail_sender, install_mail_sender
|
|
13
13
|
from simple_module_core.settings_hydrate import hydrate_settings
|
|
14
14
|
|
|
15
|
-
from mail import constants as c
|
|
16
|
-
from mail.
|
|
17
|
-
from mail.
|
|
15
|
+
from mail.core import constants as c
|
|
16
|
+
from mail.core.settings import MailSettings
|
|
17
|
+
from mail.delivery.sender import build_sender
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
async def resolve_sender_from_db(db: Any) -> MailSender:
|
|
@@ -8,8 +8,8 @@ from email.message import EmailMessage
|
|
|
8
8
|
import aiosmtplib
|
|
9
9
|
from simple_module_core.mail import ConsoleMailSender, MailMessage, MailSender
|
|
10
10
|
|
|
11
|
-
from mail import constants as c
|
|
12
|
-
from mail.settings import MailSettings
|
|
11
|
+
from mail.core import constants as c
|
|
12
|
+
from mail.core.settings import MailSettings
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class SmtpMailSender:
|
|
@@ -8,7 +8,7 @@ from simple_module_core.health import HealthCheck, HealthRegistry
|
|
|
8
8
|
from simple_module_core.mail import install_mail_resolver, install_mail_sender
|
|
9
9
|
from simple_module_core.module import ModuleBase, ModuleMeta
|
|
10
10
|
|
|
11
|
-
from mail import constants as c
|
|
11
|
+
from mail.core import constants as c
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from fastapi import FastAPI
|
|
@@ -26,15 +26,15 @@ class MailModule(ModuleBase):
|
|
|
26
26
|
def register_settings(self, app: FastAPI) -> None:
|
|
27
27
|
from simple_module_core.module_settings import register_module_settings
|
|
28
28
|
|
|
29
|
-
from mail.settings import MailSettings
|
|
30
|
-
from mail.state import MailState
|
|
29
|
+
from mail.core.settings import MailSettings
|
|
30
|
+
from mail.core.state import MailState
|
|
31
31
|
|
|
32
32
|
register_module_settings(
|
|
33
33
|
app, c.MODULE_PACKAGE, MailSettings, lambda s: MailState(settings=s)
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
def register_health_checks(self, registry: HealthRegistry) -> None:
|
|
37
|
-
from mail.runtime import check_smtp
|
|
37
|
+
from mail.delivery.runtime import check_smtp
|
|
38
38
|
|
|
39
39
|
registry.add(
|
|
40
40
|
HealthCheck(
|
|
@@ -49,7 +49,7 @@ class MailModule(ModuleBase):
|
|
|
49
49
|
def register_event_handlers(self, bus: EventBus, app: FastAPI | None = None) -> None:
|
|
50
50
|
# Before the ``app is None`` return: the outbox worker builds modules
|
|
51
51
|
# without an app and still has to send durable mail.
|
|
52
|
-
from mail.runtime import resolve_sender_from_db
|
|
52
|
+
from mail.delivery.runtime import resolve_sender_from_db
|
|
53
53
|
|
|
54
54
|
install_mail_resolver(resolve_sender_from_db)
|
|
55
55
|
if app is None:
|
|
@@ -57,7 +57,7 @@ class MailModule(ModuleBase):
|
|
|
57
57
|
|
|
58
58
|
from settings.contracts.events import SettingsReloaded
|
|
59
59
|
|
|
60
|
-
from mail.runtime import install_app_sender
|
|
60
|
+
from mail.delivery.runtime import install_app_sender
|
|
61
61
|
|
|
62
62
|
async def _reinstall(event: SettingsReloaded) -> None:
|
|
63
63
|
if event.package != c.MODULE_PACKAGE:
|
|
@@ -67,12 +67,12 @@ class MailModule(ModuleBase):
|
|
|
67
67
|
bus.subscribe(SettingsReloaded, _reinstall)
|
|
68
68
|
|
|
69
69
|
async def check_data_compatibility(self, db: Any) -> list[DataCompatibilityIssue]:
|
|
70
|
-
from mail.data_compatibility import check_data_compatibility
|
|
70
|
+
from mail.core.data_compatibility import check_data_compatibility
|
|
71
71
|
|
|
72
72
|
return await check_data_compatibility(db)
|
|
73
73
|
|
|
74
74
|
async def on_startup(self, app: FastAPI) -> None:
|
|
75
|
-
from mail.runtime import install_app_sender
|
|
75
|
+
from mail.delivery.runtime import install_app_sender
|
|
76
76
|
|
|
77
77
|
install_app_sender(app)
|
|
78
78
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`mail.core.settings`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("mail.settings", remove_in="0.0.46", use="mail.core.settings")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("mail.core.settings")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_mail"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.44"
|
|
4
4
|
description = "Outgoing mail (SMTP or console) for simple_module apps, configured from the DB-backed settings"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -9,8 +9,8 @@ requires-python = ">=3.12"
|
|
|
9
9
|
authors = [{ name = "Anto Subash", email = "antosubash@live.com" }]
|
|
10
10
|
keywords = ["simple-module", "mail", "smtp", "email"]
|
|
11
11
|
dependencies = [
|
|
12
|
-
"simple_module_core==0.0.
|
|
13
|
-
"simple_module_settings==0.0.
|
|
12
|
+
"simple_module_core==0.0.44",
|
|
13
|
+
"simple_module_settings==0.0.44",
|
|
14
14
|
"aiosmtplib>=3.0,<6",
|
|
15
15
|
]
|
|
16
16
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from mail.sender import SmtpMailSender
|
|
5
|
+
from mail.delivery.sender import SmtpMailSender
|
|
6
6
|
from settings.contracts.events import SettingsReloaded
|
|
7
|
-
from settings.
|
|
8
|
-
from settings.
|
|
9
|
-
from settings.store import SettingsStore
|
|
7
|
+
from settings.core.service import SettingService
|
|
8
|
+
from settings.module_settings.reload import apply_changes_and_reload
|
|
9
|
+
from settings.module_settings.store import SettingsStore
|
|
10
10
|
from simple_module_core import mail as core_mail
|
|
11
11
|
from simple_module_core.mail import ConsoleMailSender, resolve_mail_sender
|
|
12
12
|
from simple_module_db.transaction import finalize_session
|
|
@@ -11,7 +11,7 @@ from alembic.config import Config
|
|
|
11
11
|
|
|
12
12
|
BEFORE = "c8e4f1a2b6d9"
|
|
13
13
|
REVISION = "d7b3a9e5c1f2"
|
|
14
|
-
SCRIPTS = Path(__file__).resolve().parents[
|
|
14
|
+
SCRIPTS = Path(__file__).resolve().parents[5] / "host" / "migrations"
|
|
15
15
|
|
|
16
16
|
pytestmark = pytest.mark.filterwarnings("ignore:Skipped unsupported reflection")
|
|
17
17
|
|
|
@@ -5,8 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
from unittest.mock import AsyncMock, MagicMock
|
|
6
6
|
|
|
7
7
|
import pytest
|
|
8
|
-
from mail.runtime import check_smtp
|
|
9
|
-
from mail.sender import SmtpMailSender
|
|
8
|
+
from mail.delivery.runtime import check_smtp
|
|
9
|
+
from mail.delivery.sender import SmtpMailSender
|
|
10
10
|
from simple_module_core import mail as core_mail
|
|
11
11
|
from simple_module_core.health import HealthStatus
|
|
12
12
|
from simple_module_core.mail import ConsoleMailSender
|
|
@@ -30,7 +30,7 @@ def smtp_client(monkeypatch) -> MagicMock:
|
|
|
30
30
|
client.connect = AsyncMock()
|
|
31
31
|
client.login = AsyncMock()
|
|
32
32
|
client.quit = AsyncMock()
|
|
33
|
-
monkeypatch.setattr("mail.sender.aiosmtplib.SMTP", MagicMock(return_value=client))
|
|
33
|
+
monkeypatch.setattr("mail.delivery.sender.aiosmtplib.SMTP", MagicMock(return_value=client))
|
|
34
34
|
core_mail.install_mail_sender(SmtpMailSender("h", 587, "user", "pw", "f@test", True))
|
|
35
35
|
return client
|
|
36
36
|
|
|
@@ -5,8 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
from unittest.mock import AsyncMock
|
|
6
6
|
|
|
7
7
|
import pytest
|
|
8
|
-
from mail.
|
|
9
|
-
from mail.
|
|
8
|
+
from mail.core.settings import MailSettings
|
|
9
|
+
from mail.delivery.sender import SmtpMailSender, build_sender
|
|
10
10
|
from simple_module_core.mail import ConsoleMailSender, MailMessage
|
|
11
11
|
|
|
12
12
|
|
|
@@ -42,7 +42,7 @@ def _smtp() -> SmtpMailSender:
|
|
|
42
42
|
|
|
43
43
|
async def test_send_builds_a_plain_text_message(monkeypatch) -> None:
|
|
44
44
|
send = AsyncMock()
|
|
45
|
-
monkeypatch.setattr("mail.sender.aiosmtplib.send", send)
|
|
45
|
+
monkeypatch.setattr("mail.delivery.sender.aiosmtplib.send", send)
|
|
46
46
|
|
|
47
47
|
await _smtp().send(MailMessage(to="to@test", subject="Hi", text="Body"))
|
|
48
48
|
|
|
@@ -62,7 +62,7 @@ async def test_send_builds_a_plain_text_message(monkeypatch) -> None:
|
|
|
62
62
|
|
|
63
63
|
async def test_send_adds_an_html_alternative(monkeypatch) -> None:
|
|
64
64
|
send = AsyncMock()
|
|
65
|
-
monkeypatch.setattr("mail.sender.aiosmtplib.send", send)
|
|
65
|
+
monkeypatch.setattr("mail.delivery.sender.aiosmtplib.send", send)
|
|
66
66
|
|
|
67
67
|
await _smtp().send(MailMessage(to="to@test", subject="Hi", text="Body", html="<b>Body</b>"))
|
|
68
68
|
|
|
@@ -74,7 +74,7 @@ async def test_send_adds_an_html_alternative(monkeypatch) -> None:
|
|
|
74
74
|
|
|
75
75
|
async def test_blank_credentials_are_sent_as_none(monkeypatch) -> None:
|
|
76
76
|
send = AsyncMock()
|
|
77
|
-
monkeypatch.setattr("mail.sender.aiosmtplib.send", send)
|
|
77
|
+
monkeypatch.setattr("mail.delivery.sender.aiosmtplib.send", send)
|
|
78
78
|
|
|
79
79
|
sender = SmtpMailSender("h", 25, "", "", "f@test", False)
|
|
80
80
|
await sender.send(MailMessage(to="t@test", subject="s", text="b"))
|
|
@@ -85,8 +85,8 @@ async def test_blank_credentials_are_sent_as_none(monkeypatch) -> None:
|
|
|
85
85
|
|
|
86
86
|
def test_console_backend_outside_development_does_not_log_bodies() -> None:
|
|
87
87
|
"""Reset and invite bodies carry one-time tokens (production console backend)."""
|
|
88
|
-
from mail.
|
|
89
|
-
from mail.
|
|
88
|
+
from mail.core.settings import MailSettings
|
|
89
|
+
from mail.delivery.sender import build_sender
|
|
90
90
|
|
|
91
91
|
assert build_sender(MailSettings(), log_bodies=False).include_body is False
|
|
92
92
|
assert build_sender(MailSettings()).include_body is True
|
|
@@ -94,7 +94,7 @@ def test_console_backend_outside_development_does_not_log_bodies() -> None:
|
|
|
94
94
|
|
|
95
95
|
@pytest.mark.parametrize("port", [-1, 0, 65536, 99999])
|
|
96
96
|
def test_smtp_port_outside_the_tcp_range_is_rejected(port) -> None:
|
|
97
|
-
from mail.settings import MailSettings
|
|
97
|
+
from mail.core.settings import MailSettings
|
|
98
98
|
from pydantic import ValidationError
|
|
99
99
|
|
|
100
100
|
with pytest.raises(ValidationError):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|