mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
more precise test, streamline wording (accounts -> address)
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user