SHA256
forked from course-team/tjhlp-gitea
refactor: 移除 SMTP 相关代码,简化用户创建流程,更新文档
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user