Mercurial > libervia-backend
comparison tests/e2e/conftest.py @ 3436:f9011d62a87a
tests (e2e/conftest): check new exit code for conflict to avoid crashing if test accounts already exist
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 04 Dec 2020 12:34:24 +0100 |
parents | d4558f3cbf13 |
children | 42d6d00e4e8a |
comparison
equal
deleted
inserted
replaced
3435:df775db4c49b | 3436:f9011d62a87a |
---|---|
23 import random | 23 import random |
24 from pathlib import Path | 24 from pathlib import Path |
25 from aiosmtpd.controller import Controller | 25 from aiosmtpd.controller import Controller |
26 from aiosmtpd.handlers import Message | 26 from aiosmtpd.handlers import Message |
27 from email.message import EmailMessage | 27 from email.message import EmailMessage |
28 import sh | |
28 from sh import jp | 29 from sh import jp |
29 import pytest | 30 import pytest |
30 | 31 |
31 | 32 |
32 class FakeFile: | 33 class FakeFile: |
153 account_stop = accounts_by_servers[server_idx] + 1 | 154 account_stop = accounts_by_servers[server_idx] + 1 |
154 for account_idx in range(1, account_stop): | 155 for account_idx in range(1, account_stop): |
155 profile_suff = f"_s{server_idx}" if server_idx>1 else "" | 156 profile_suff = f"_s{server_idx}" if server_idx>1 else "" |
156 profile = f"account{account_idx}{profile_suff}" | 157 profile = f"account{account_idx}{profile_suff}" |
157 profiles.append(profile) | 158 profiles.append(profile) |
158 jp.account.create( | 159 try: |
159 f"account{account_idx}@server{server_idx}.test", | 160 jp.account.create( |
160 "test", | 161 f"account{account_idx}@server{server_idx}.test", |
161 profile=profile, | 162 "test", |
162 host=f"server{server_idx}.test" | 163 profile=profile, |
163 ) | 164 host=f"server{server_idx}.test" |
165 ) | |
166 except sh.ErrorReturnCode_19: | |
167 # this is the conlict exit code, this can happen when tests are run | |
168 # inside a container when --keep-profiles is used with run_e2e.py. | |
169 pass | |
164 jp.profile.modify(profile="account1", default=True, connect=True) | 170 jp.profile.modify(profile="account1", default=True, connect=True) |
165 jp.profile.connect(profile="account1_s2", connect=True) | 171 jp.profile.connect(profile="account1_s2", connect=True) |
166 yield tuple(profiles) | 172 yield tuple(profiles) |
167 # This environment may be used during tests development | 173 # This environment may be used during tests development |
168 if os.getenv("SAT_TEST_E2E_KEEP_PROFILES") == None: | 174 if os.getenv("SAT_TEST_E2E_KEEP_PROFILES") == None: |