mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
fix and streamline deletion test
This commit is contained in:
@@ -15,6 +15,7 @@ def test_remove_stale_users(db, example_config):
|
|||||||
md.joinpath("cur").mkdir()
|
md.joinpath("cur").mkdir()
|
||||||
md.joinpath("cur", "something").mkdir()
|
md.joinpath("cur", "something").mkdir()
|
||||||
|
|
||||||
|
# create some stale and some new accounts
|
||||||
to_remove = []
|
to_remove = []
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
addr = f"oldold{i:03}@chat.example.org"
|
addr = f"oldold{i:03}@chat.example.org"
|
||||||
@@ -25,19 +26,24 @@ def test_remove_stale_users(db, example_config):
|
|||||||
|
|
||||||
remain = []
|
remain = []
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
create_user(f"newnew{i:03}@chat.example.org", last_login=new)
|
addr = f"newnew{i:03}@chat.example.org"
|
||||||
|
create_user(addr, last_login=new)
|
||||||
|
remain.append(addr)
|
||||||
|
|
||||||
udir = example_config.get_user_maildir("oldold001@chat.example.org")
|
# check pre and post-conditions for delete_inactive_users()
|
||||||
assert udir.exists()
|
|
||||||
|
for addr in to_remove:
|
||||||
|
assert example_config.get_user_maildir(addr).exists()
|
||||||
|
|
||||||
delete_inactive_users(db, example_config)
|
delete_inactive_users(db, example_config)
|
||||||
|
|
||||||
for p in udir.parent.iterdir():
|
for p in example_config.mail_basedir.iterdir():
|
||||||
assert not p.name.startswith("old")
|
assert not p.name.startswith("old")
|
||||||
|
|
||||||
for addr in to_remove:
|
for addr in to_remove:
|
||||||
with db.read_connection() as conn:
|
with db.read_connection() as conn:
|
||||||
assert not conn.get_user(addr)
|
assert not conn.get_user(addr)
|
||||||
|
assert not example_config.get_user_maildir(addr).exists()
|
||||||
|
|
||||||
for addr in remain:
|
for addr in remain:
|
||||||
assert example_config.get_user_maildir(addr).exists()
|
assert example_config.get_user_maildir(addr).exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user