feat(mailu): add ops.py + backup/restore tests + update PARITY.md (P4 now covered via PR#3)
This commit is contained in:
36
tests/mailu/ops.py
Normal file
36
tests/mailu/ops.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""mailu — pre-op seed hooks. Creates / deletes a test mailbox in the admin sqlite DB to prove
|
||||
backup→restore data integrity on real mail data (P4 coverage, phase-mailu)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
|
||||
from harness import lifecycle # noqa: E402
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
import _mailu # noqa: E402
|
||||
|
||||
_CI_LOCALPART = "citest"
|
||||
_CI_PASSWORD = "CcCi-BackupTest1!Aa"
|
||||
|
||||
|
||||
def pre_backup(ctx):
|
||||
_mailu.ensure_domain(ctx.domain, ctx.domain)
|
||||
_mailu.create_user(ctx.domain, _CI_LOCALPART, ctx.domain, _CI_PASSWORD)
|
||||
|
||||
|
||||
def pre_restore(ctx):
|
||||
# Delete the seeded user directly from sqlite to simulate data loss before restore.
|
||||
# (flask mailu has no user-delete subcommand in 2024.06.52; sqlite3 module is always available.)
|
||||
lifecycle.exec_in_app(
|
||||
ctx.domain,
|
||||
[
|
||||
"python3",
|
||||
"-c",
|
||||
f"import sqlite3; db=sqlite3.connect('/data/main.db'); "
|
||||
f"db.execute(\"DELETE FROM user WHERE localpart='{_CI_LOCALPART}'\"); db.commit()",
|
||||
],
|
||||
service="admin",
|
||||
)
|
||||
Reference in New Issue
Block a user