MCPcopy Create free account
hub / github.com/chatmail/core / get_liveconfig_producer

Method get_liveconfig_producer

python/src/deltachat/testplugin.py:159–184  ·  view source on GitHub ↗

provide live account configs, cached on a per-test-process scope so that test functions can reuse already known live configs.

(self)

Source from the content-addressed store, hash-verified

157 self._configlist: List[Dict[str, str]] = []
158
159 def get_liveconfig_producer(self):
160 """provide live account configs, cached on a per-test-process scope
161 so that test functions can reuse already known live configs.
162 """
163 chatmail_opt = self.pytestconfig.getoption("--chatmail")
164 if chatmail_opt:
165 # Use a chatmail instance.
166 domain = chatmail_opt
167 MAX_LIVE_CREATED_ACCOUNTS = 10
168 for index in range(MAX_LIVE_CREATED_ACCOUNTS):
169 try:
170 yield self._configlist[index]
171 except IndexError:
172 part = "".join(random.choices("2345789acdefghjkmnpqrstuvwxyz", k=6))
173 username = f"ci-{part}"
174 password = f"{username}${username}"
175 addr = f"{username}@{domain}"
176 config = {"addr": addr, "mail_pw": password}
177 print("newtmpuser {}: addr={}".format(index, config["addr"]))
178 self._configlist.append(config)
179 yield config
180 pytest.fail(f"more than {MAX_LIVE_CREATED_ACCOUNTS} live accounts requested.")
181 else:
182 pytest.skip(
183 "specify CHATMAIL_DOMAIN or --chatmail to provide live accounts",
184 )
185
186 def cache_maybe_retrieve_configured_db_files(self, cache_addr, db_target_path):
187 db_target_path = pathlib.Path(db_target_path)

Callers 1

__init__Method · 0.80

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected