SHA256
forked from course-team/tjhlp-gitea
refactor: 移除 SMTP 相关代码,简化用户创建流程,更新文档
This commit is contained in:
@@ -104,9 +104,7 @@ class TestUsersCreateDryRun:
|
||||
class TestUsersCreate:
|
||||
@patch("tjhlp.commands.users.GiteaClient")
|
||||
@patch("tjhlp.commands.users.get_gitea_config")
|
||||
def test_creates_users_and_outputs_credentials(
|
||||
self, mock_get_cfg, mock_client_cls, mock_config, tmp_path: Path
|
||||
):
|
||||
def test_creates_users(self, mock_get_cfg, mock_client_cls, mock_config, tmp_path: Path):
|
||||
mock_get_cfg.return_value = mock_config
|
||||
client = MagicMock()
|
||||
client.__enter__ = MagicMock(return_value=client)
|
||||
@@ -118,7 +116,6 @@ class TestUsersCreate:
|
||||
|
||||
csv_file = tmp_path / "members.csv"
|
||||
csv_file.write_text("id,name,role\n2659999,赵一伤,student\n", encoding="utf-8")
|
||||
out_file = tmp_path / "creds.csv"
|
||||
|
||||
result = runner.invoke(
|
||||
app,
|
||||
@@ -127,20 +124,17 @@ class TestUsersCreate:
|
||||
"create",
|
||||
"--file",
|
||||
str(csv_file),
|
||||
"--output",
|
||||
str(out_file),
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "创建" in result.output
|
||||
assert out_file.exists()
|
||||
|
||||
# Verify credentials CSV
|
||||
with open(out_file, encoding="utf-8") as f:
|
||||
rows = list(csv.DictReader(f))
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["id"] == "2659999"
|
||||
assert len(rows[0]["password"]) >= 8
|
||||
client.create_user.assert_called_once_with(
|
||||
username="2659999",
|
||||
password="2659999",
|
||||
email="[email protected]",
|
||||
full_name="赵一伤",
|
||||
must_change_password=True,
|
||||
)
|
||||
|
||||
@patch("tjhlp.commands.users.GiteaClient")
|
||||
@patch("tjhlp.commands.users.get_gitea_config")
|
||||
|
||||
Reference in New Issue
Block a user