Skip to content

Commit b88042a

Browse files
committed
python: display configuration failure error
When configure fails, display error comment in pytest failure message.
1 parent dc29ede commit b88042a

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

python/src/deltachat/events.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ def _map_ffi_event(self, ffi_event: FFIEvent):
271271
data1 = ffi_event.data1
272272
if data1 == 0 or data1 == 1000:
273273
success = data1 == 1000
274-
yield "ac_configure_completed", dict(success=success)
274+
comment = ffi_event.data2
275+
yield "ac_configure_completed", dict(success=success, comment=comment)
275276
elif name == "DC_EVENT_INCOMING_MSG":
276277
msg = account.get_message_by_id(ffi_event.data2)
277278
yield map_system_message(msg) or ("ac_incoming_message", dict(message=msg))

python/src/deltachat/hookspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def ac_log_line(self, message):
3838
"""log a message related to the account."""
3939

4040
@account_hookspec
41-
def ac_configure_completed(self, success):
41+
def ac_configure_completed(self, success, comment):
4242
"""Called after a configure process completed."""
4343

4444
@account_hookspec

python/src/deltachat/testplugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ def start_configure(self, account, reconfigure=False):
294294

295295
class PendingTracker:
296296
@account_hookimpl
297-
def ac_configure_completed(this, success):
298-
self._configured_events.put((account, success))
297+
def ac_configure_completed(this, success: bool, comment: Optional[str]) -> None:
298+
self._configured_events.put((account, success, comment))
299299

300300
account.add_account_plugin(PendingTracker(), name="pending_tracker")
301301
self._account2state[account] = self.CONFIGURING
@@ -333,9 +333,9 @@ def bring_online(self):
333333
print("finished, account2state", self._account2state)
334334

335335
def _pop_config_success(self):
336-
acc, success = self._configured_events.get()
336+
acc, success, comment = self._configured_events.get()
337337
if not success:
338-
pytest.fail("configuring online account failed: {}".format(acc))
338+
pytest.fail("configuring online account {} failed: {}".format(acc, comment))
339339
self._account2state[acc] = self.CONFIGURED
340340
return acc
341341

python/tests/test_4_lowlevel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_basic_states(self, acfactory, monkeypatch, testprocess):
3535
monkeypatch.setattr(acc, "configure", lambda **kwargs: None)
3636
pc.start_configure(acc)
3737
assert pc._account2state[acc] == pc.CONFIGURING
38-
pc._configured_events.put((acc, True))
38+
pc._configured_events.put((acc, True, None))
3939
monkeypatch.setattr(pc, "init_imap", lambda *args, **kwargs: None)
4040
pc.wait_one_configured(acc)
4141
assert pc._account2state[acc] == pc.CONFIGURED
@@ -55,11 +55,11 @@ def test_two_accounts_one_waited_all_started(self, monkeypatch, acfactory, testp
5555
pc.start_configure(ac2)
5656
assert pc._account2state[ac1] == pc.CONFIGURING
5757
assert pc._account2state[ac2] == pc.CONFIGURING
58-
pc._configured_events.put((ac1, True))
58+
pc._configured_events.put((ac1, True, None))
5959
pc.wait_one_configured(ac1)
6060
assert pc._account2state[ac1] == pc.CONFIGURED
6161
assert pc._account2state[ac2] == pc.CONFIGURING
62-
pc._configured_events.put((ac2, True))
62+
pc._configured_events.put((ac2, True, None))
6363
pc.bring_online()
6464
assert pc._account2state[ac1] == pc.IDLEREADY
6565
assert pc._account2state[ac2] == pc.IDLEREADY

0 commit comments

Comments
 (0)