Files
cc-ci/tests/mailu/test_restore.py
autonomic-bot 1be74fb9e1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
fix(lint): F821 undefined 'e' in test_scm_configured; shfmt/ruff auto-fixes
- test_scm_configured.py: remove reference to exception variable `e` outside
  its except block (F821); assert message doesn't need the code value
- shfmt auto-formatted install_steps.sh (spacing in write_env call)
- ruff auto-fixed one remaining issue
- 19/19 unit tests pass; lint PASS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 22:17:19 +00:00

49 lines
1.6 KiB
Python

"""mailu — RESTORE overlay: assert both the seeded mailbox (sqlite /data) and the injected
mail message (imap /mail) are back after restore.
ops.pre_restore deleted the user from sqlite AND wiped the maildir to simulate full data
loss on both volumes; this overlay asserts that abra app restore brings back both the
account record (from /data) and the stored message (from /mail)."""
from __future__ import annotations
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "functional"))
import _mailu # noqa: E402
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
from harness import lifecycle # noqa: E402
_CI_LOCALPART = "citest"
_CI_MAIL_SUBJECT = "ccci-backup-probe"
def test_restore_returns_mailbox(live_app):
email = f"{_CI_LOCALPART}@{live_app}"
cfg = _mailu.config_export(live_app)
emails = _mailu.user_emails(cfg)
assert email in emails, (
f"seeded mailbox {email!r} not found in config-export after restore; "
f"the /data (sqlite) volume was not restored. "
f"users present: {emails}"
)
def test_restore_returns_mail_message(live_app):
email = f"{_CI_LOCALPART}@{live_app}"
out = lifecycle.exec_in_app(
live_app,
[
"sh",
"-c",
f"doveadm search -u '{email}' mailbox INBOX header subject '{_CI_MAIL_SUBJECT}'",
],
service="imap",
)
assert out.strip(), (
f"test message {_CI_MAIL_SUBJECT!r} not found in INBOX for {email!r} after restore; "
f"the /mail (Maildir) volume was not restored from the backup snapshot"
)