deploy: auto commit repo-root changes 2026-06-13 00:33:38
This commit is contained in:
@@ -80,6 +80,32 @@ class FakeClient:
|
||||
)
|
||||
|
||||
|
||||
class RecordingCursor:
|
||||
def __init__(self):
|
||||
self.executed = []
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc, tb):
|
||||
return False
|
||||
|
||||
def execute(self, sql, params=None):
|
||||
self.executed.append((sql, params))
|
||||
|
||||
|
||||
class RecordingConnection:
|
||||
def __init__(self):
|
||||
self.cursor_obj = RecordingCursor()
|
||||
self.commits = 0
|
||||
|
||||
def cursor(self):
|
||||
return self.cursor_obj
|
||||
|
||||
def commit(self):
|
||||
self.commits += 1
|
||||
|
||||
|
||||
class AiCommentDispatchTest(unittest.TestCase):
|
||||
def test_merge_candidates_merges_selection_sources_by_target(self):
|
||||
merged = merge_candidates(
|
||||
@@ -217,6 +243,29 @@ class AiCommentDispatchTest(unittest.TestCase):
|
||||
self.assertNotIn("·", nickname)
|
||||
self.assertGreaterEqual(len(nickname), 3)
|
||||
|
||||
def test_existing_virtual_user_nickname_comes_from_user_table(self):
|
||||
repo = AiCommentRepository.__new__(AiCommentRepository)
|
||||
repo.prefix = "la_"
|
||||
repo.conn = RecordingConnection()
|
||||
repo._virtual_users_cache = None
|
||||
repo._settings_cache = None
|
||||
existing_rows = [
|
||||
{
|
||||
"id": 83,
|
||||
"account": "ai_comment_0001",
|
||||
"nickname": "赛点阿泽已手动改名",
|
||||
"avatar": "/avatar.png",
|
||||
}
|
||||
]
|
||||
repo._load_virtual_users = lambda limit=None: list(existing_rows)
|
||||
repo._load_site_config = lambda group, name: ""
|
||||
|
||||
users = repo.ensure_virtual_users(1)
|
||||
|
||||
self.assertEqual(users[0].nickname, "赛点阿泽已手动改名")
|
||||
executed_sql = "\n".join(sql for sql, _ in repo.conn.cursor_obj.executed)
|
||||
self.assertNotIn("UPDATE `la_user` SET nickname", executed_sql)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user