mirror of
https://github.com/chatmail/relay.git
synced 2026-05-17 20:28:59 +00:00
let config.get_user_maildir return a Path
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from chatmaild.delete_inactive_users import delete_inactive_users
|
||||
from chatmaild.doveauth import lookup_passdb
|
||||
@@ -9,12 +8,9 @@ def test_remove_stale_users(db, example_config):
|
||||
new = time.time()
|
||||
old = new - (example_config.delete_inactive_users_after * 86400) - 1
|
||||
|
||||
def get_user_path(addr):
|
||||
return Path(example_config.get_user_maildir(addr))
|
||||
|
||||
def create_user(addr, last_login):
|
||||
lookup_passdb(db, example_config, addr, "q9mr3faue", last_login=last_login)
|
||||
md = get_user_path(addr)
|
||||
md = example_config.get_user_maildir(addr)
|
||||
md.mkdir(parents=True)
|
||||
md.joinpath("cur").mkdir()
|
||||
md.joinpath("cur", "something").mkdir()
|
||||
@@ -37,7 +33,7 @@ def test_remove_stale_users(db, example_config):
|
||||
# check pre and post-conditions for delete_inactive_users()
|
||||
|
||||
for addr in to_remove:
|
||||
assert get_user_path(addr).exists()
|
||||
assert example_config.get_user_maildir(addr).exists()
|
||||
|
||||
delete_inactive_users(db, example_config)
|
||||
|
||||
@@ -45,11 +41,11 @@ def test_remove_stale_users(db, example_config):
|
||||
assert not p.name.startswith("old")
|
||||
|
||||
for addr in to_remove:
|
||||
assert not get_user_path(addr).exists()
|
||||
assert not example_config.get_user_maildir(addr).exists()
|
||||
with db.read_connection() as conn:
|
||||
assert not conn.get_user(addr)
|
||||
|
||||
for addr in remain:
|
||||
assert get_user_path(addr).exists()
|
||||
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