From 9b15d8de245aca6fa94d96314ae876c7cbb0cbea Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 9 Jul 2024 11:50:10 +0200 Subject: [PATCH] more precise test, streamline wording (accounts -> address) --- chatmaild/src/chatmaild/doveauth.py | 2 +- .../chatmaild/tests/test_delete_inactive_users.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/chatmaild/src/chatmaild/doveauth.py b/chatmaild/src/chatmaild/doveauth.py index 13a49de4..172e4d9a 100644 --- a/chatmaild/src/chatmaild/doveauth.py +++ b/chatmaild/src/chatmaild/doveauth.py @@ -124,7 +124,7 @@ def lookup_passdb(db, config: Config, user, cleartext_password, last_login=None) q = """INSERT INTO users (addr, password, last_login) VALUES (?, ?, ?)""" conn.execute(q, (user, encrypted_password, last_login)) - print(f"Created account {user}", file=sys.stderr) + print(f"Created e-mail address: {user}", file=sys.stderr) return dict( home=f"/home/vmail/mail/{config.mail_domain}/{user}", uid="vmail", diff --git a/chatmaild/src/chatmaild/tests/test_delete_inactive_users.py b/chatmaild/src/chatmaild/tests/test_delete_inactive_users.py index a51f1ca9..86767eae 100644 --- a/chatmaild/src/chatmaild/tests/test_delete_inactive_users.py +++ b/chatmaild/src/chatmaild/tests/test_delete_inactive_users.py @@ -15,8 +15,13 @@ def test_remove_stale_users(db, example_config): md.joinpath("cur").mkdir() md.joinpath("cur", "something").mkdir() + to_remove = [] for i in range(10): - create_user(f"oldold{i:03}@chat.example.org", last_login=old) + addr = f"oldold{i:03}@chat.example.org" + create_user(addr, last_login=old) + with db.read_connection() as conn: + assert conn.get_user(addr) + to_remove.append(addr) remain = [] for i in range(5): @@ -30,5 +35,11 @@ def test_remove_stale_users(db, example_config): for p in udir.parent.iterdir(): assert not p.name.startswith("old") + for addr in to_remove: + with db.read_connection() as conn: + assert not conn.get_user(addr) + for addr in remain: assert example_config.get_user_maildir(addr).exists() + with db.read_connection() as conn: + assert conn.get_user(addr)