feat: add HTML email body for --send (#48)
Add email.html config flag (default false). When enabled, --send includes an HTML version of the report body generated via HTMLFormatter alongside the plain-text part in a multipart/alternative message. - EmailConfig gains html: bool field - mailer.build_message/send_report accept rows for HTML generation - CLI passes rows to send_report - --init-config generates email.html: false - README.md and docs/CONFIG.md updated Bump version to 1.10.0. Closes #48
This commit is contained in:
@@ -5,7 +5,12 @@ from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from redmine_reporter.config import DEFAULT_REDMINE_VERIFY, AppConfig, Config
|
||||
from redmine_reporter.config import (
|
||||
DEFAULT_REDMINE_VERIFY,
|
||||
AppConfig,
|
||||
Config,
|
||||
EmailConfig,
|
||||
)
|
||||
|
||||
|
||||
@mock.patch.dict(
|
||||
@@ -613,6 +618,54 @@ class TestGetEmailConfig:
|
||||
assert Config.get_email_config() is None
|
||||
|
||||
|
||||
class TestEmailConfigHtml:
|
||||
"""Tests for EmailConfig.html field."""
|
||||
|
||||
def test_email_config_html_from_yaml(self):
|
||||
"""email.html: true загружается из YAML."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text(
|
||||
"email:\n html: true\n smtp:\n host: smtp.example.com\n"
|
||||
)
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.email.html is True
|
||||
|
||||
def test_email_config_html_defaults_to_false(self):
|
||||
"""email.html по умолчанию False."""
|
||||
assert EmailConfig().html is False
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text("email:\n smtp:\n host: smtp.example.com\n")
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.email.html is False
|
||||
|
||||
def test_email_config_html_false_from_yaml(self):
|
||||
"""email.html: false явно загружается из YAML."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text(
|
||||
"email:\n html: false\n smtp:\n host: smtp.example.com\n"
|
||||
)
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.email.html is False
|
||||
|
||||
def test_email_config_html_invalid_string_defaults_to_false(self):
|
||||
"""email.html со строкой 'invalid' приводится к False."""
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text(
|
||||
"email:\n html: 'invalid'\n smtp:\n host: smtp.example.com\n"
|
||||
)
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.email.html is False
|
||||
|
||||
|
||||
class TestReportNoTime:
|
||||
"""Tests for Config.get_report_no_time()."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user