refactor: 移除 SMTP 相关代码,简化用户创建流程,更新文档

This commit is contained in:
2026-04-13 12:27:14 +08:00
parent 919c561629
commit 66c254e0ff
13 changed files with 41 additions and 466 deletions
+1 -26
View File
@@ -7,7 +7,7 @@ from typing import Any
import pytest
from pydantic import HttpUrl, SecretStr, ValidationError
from tjhlp.config import GiteaConfig, LabelDef, SmtpConfig
from tjhlp.config import GiteaConfig, LabelDef
class TestLabelDef:
@@ -63,7 +63,6 @@ class TestGiteaConfig:
token=SecretStr("token123"),
)
assert cfg.email_domain == "tongji.edu.cn"
assert cfg.password_length == 16
assert cfg.labels == []
def test_missing_url_raises(self):
@@ -92,27 +91,3 @@ class TestGiteaConfig:
labels=[LabelDef(name="bug", color="#ff0000")],
)
assert len(cfg.labels) == 1
class TestSmtpConfig:
def test_valid(self):
cfg = SmtpConfig(
host="smtp.test.com",
user="[email protected]",
password=SecretStr("pass123"),
)
assert cfg.port == 465
assert cfg.from_addr == ""
def test_missing_host_raises(self):
with pytest.raises(ValidationError):
kwargs: dict[str, Any] = {"user": "user", "password": SecretStr("pass")}
SmtpConfig(**kwargs)
def test_password_is_secret(self):
cfg = SmtpConfig(
host="smtp.test.com",
user="[email protected]",
password=SecretStr("my-secret"),
)
assert cfg.password.get_secret_value() == "my-secret"