Mercurial > libervia-backend
comparison tests/e2e/conftest.py @ 3498:d78b5eae912a
tests: update following names change
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 16 Apr 2021 18:32:34 +0200 |
parents | 7550ae9cfbac |
children | 4cd4922de876 |
comparison
equal
deleted
inserted
replaced
3497:73e04040d577 | 3498:d78b5eae912a |
---|---|
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 import sh |
29 from sh import jp | 29 from sh import li |
30 import pytest | 30 import pytest |
31 | 31 |
32 | 32 |
33 class FakeFile: | 33 class FakeFile: |
34 ALPHABET = f"{string.ascii_letters}{string.digits}_" | 34 ALPHABET = f"{string.ascii_letters}{string.digits}_" |
35 BUF_SIZE = 65535 | 35 BUF_SIZE = 65535 |
36 | 36 |
37 def __init__(self): | 37 def __init__(self): |
38 self.tmp_dir_obj = tempfile.TemporaryDirectory(prefix="sat_e2e_test_files_") | 38 self.tmp_dir_obj = tempfile.TemporaryDirectory(prefix="libervia_e2e_test_files_") |
39 self.tmp_dir_path = Path(self.tmp_dir_obj.name) | 39 self.tmp_dir_path = Path(self.tmp_dir_obj.name) |
40 self.source_files = self.tmp_dir_path / "source" | 40 self.source_files = self.tmp_dir_path / "source" |
41 self.source_files.mkdir() | 41 self.source_files.mkdir() |
42 self.dest_files = self.tmp_dir_path / "dest" | 42 self.dest_files = self.tmp_dir_path / "dest" |
43 self.dest_files.mkdir() | 43 self.dest_files.mkdir() |
155 for account_idx in range(1, account_stop): | 155 for account_idx in range(1, account_stop): |
156 profile_suff = f"_s{server_idx}" if server_idx>1 else "" | 156 profile_suff = f"_s{server_idx}" if server_idx>1 else "" |
157 profile = f"account{account_idx}{profile_suff}" | 157 profile = f"account{account_idx}{profile_suff}" |
158 profiles.append(profile) | 158 profiles.append(profile) |
159 try: | 159 try: |
160 jp.account.create( | 160 li.account.create( |
161 f"account{account_idx}@server{server_idx}.test", | 161 f"account{account_idx}@server{server_idx}.test", |
162 "test", | 162 "test", |
163 profile=profile, | 163 profile=profile, |
164 host=f"server{server_idx}.test" | 164 host=f"server{server_idx}.test" |
165 ) | 165 ) |
166 except sh.ErrorReturnCode_19: | 166 except sh.ErrorReturnCode_19: |
167 # this is the conlict exit code, this can happen when tests are run | 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. | 168 # inside a container when --keep-profiles is used with run_e2e.py. |
169 pass | 169 pass |
170 jp.profile.modify(profile="account1", default=True, connect=True) | 170 li.profile.modify(profile="account1", default=True, connect=True) |
171 jp.profile.connect(profile="account1_s2", connect=True) | 171 li.profile.connect(profile="account1_s2", connect=True) |
172 yield tuple(profiles) | 172 yield tuple(profiles) |
173 # This environment may be used during tests development | 173 # This environment may be used during tests development |
174 if os.getenv("SAT_TEST_E2E_KEEP_PROFILES") == None: | 174 if os.getenv("LIBERVIA_TEST_E2E_KEEP_PROFILES") == None: |
175 for profile in profiles: | 175 for profile in profiles: |
176 jp.account.delete(profile=profile, connect=True, force=True) | 176 li.account.delete(profile=profile, connect=True, force=True) |
177 jp.profile.delete(profile, force=True) | 177 li.profile.delete(profile, force=True) |
178 | 178 |
179 | 179 |
180 @pytest.fixture(scope="class") | 180 @pytest.fixture(scope="class") |
181 def pubsub_nodes(test_profiles): | 181 def pubsub_nodes(test_profiles): |
182 """Create 2 testing nodes | 182 """Create 2 testing nodes |
183 | 183 |
184 Both nodes will be created with "account1" profile, named "test" and have an "open" | 184 Both nodes will be created with "account1" profile, named "test" and have an "open" |
185 access model. | 185 access model. |
186 One node will account1's PEP, the other one on pubsub.server1.test. | 186 One node will be on account1's PEP, the other one on pubsub.server1.test. |
187 """ | 187 """ |
188 jp.pubsub.node.create( | 188 li.pubsub.node.create( |
189 "-f", "access_model", "open", | 189 "-f", "access_model", "open", |
190 node="test", | 190 node="test", |
191 profile="account1", connect=True | 191 profile="account1", connect=True |
192 ) | 192 ) |
193 jp.pubsub.node.create( | 193 li.pubsub.node.create( |
194 "-f", "access_model", "open", | 194 "-f", "access_model", "open", |
195 service="pubsub.server1.test", node="test", | 195 service="pubsub.server1.test", node="test", |
196 profile="account1" | 196 profile="account1" |
197 ) | 197 ) |
198 yield | 198 yield |
199 jp.pubsub.node.delete( | 199 li.pubsub.node.delete( |
200 node="test", | 200 node="test", |
201 profile="account1", connect=True, | 201 profile="account1", connect=True, |
202 force=True | 202 force=True |
203 ) | 203 ) |
204 jp.pubsub.node.delete( | 204 li.pubsub.node.delete( |
205 service="pubsub.server1.test", node="test", | 205 service="pubsub.server1.test", node="test", |
206 profile="account1", | 206 profile="account1", |
207 force=True | 207 force=True |
208 ) | 208 ) |
209 | 209 |