tests (e2e/conftest): check new exit code for conflict to avoid crashing if test accounts already exist

This commit is contained in:
Goffi 2020-12-04 12:34:24 +01:00
commit 736f91e557

View file

@ -25,6 +25,7 @@ from pathlib import Path
from aiosmtpd.controller import Controller
from aiosmtpd.handlers import Message
from email.message import EmailMessage
import sh
from sh import jp
import pytest
@ -155,12 +156,17 @@ def test_profiles():
profile_suff = f"_s{server_idx}" if server_idx>1 else ""
profile = f"account{account_idx}{profile_suff}"
profiles.append(profile)
jp.account.create(
f"account{account_idx}@server{server_idx}.test",
"test",
profile=profile,
host=f"server{server_idx}.test"
)
try:
jp.account.create(
f"account{account_idx}@server{server_idx}.test",
"test",
profile=profile,
host=f"server{server_idx}.test"
)
except sh.ErrorReturnCode_19:
# this is the conlict exit code, this can happen when tests are run
# inside a container when --keep-profiles is used with run_e2e.py.
pass
jp.profile.modify(profile="account1", default=True, connect=True)
jp.profile.connect(profile="account1_s2", connect=True)
yield tuple(profiles)