@@ -138,6 +138,8 @@ class TestProcess:
138
138
"""
139
139
def __init__ (self , pytestconfig ):
140
140
self .pytestconfig = pytestconfig
141
+ self ._addr2files = {}
142
+ self ._configlist = []
141
143
142
144
def get_liveconfig_producer (self ):
143
145
""" provide live account configs, cached on a per-test-process scope
@@ -149,22 +151,21 @@ def get_liveconfig_producer(self):
149
151
if not liveconfig_opt :
150
152
pytest .skip ("specify DCC_NEW_TMP_EMAIL or --liveconfig to provide live accounts" )
151
153
152
- configlist = []
153
154
if not liveconfig_opt .startswith ("http" ):
154
155
for line in open (liveconfig_opt ):
155
156
if line .strip () and not line .strip ().startswith ('#' ):
156
157
d = {}
157
158
for part in line .split ():
158
159
name , value = part .split ("=" )
159
160
d [name ] = value
160
- configlist .append (d )
161
+ self . _configlist .append (d )
161
162
162
- yield from iter (configlist )
163
+ yield from iter (self . _configlist )
163
164
else :
164
165
MAX_LIVE_CREATED_ACCOUNTS = 10
165
166
for index in range (MAX_LIVE_CREATED_ACCOUNTS ):
166
167
try :
167
- yield configlist [index ]
168
+ yield self . _configlist [index ]
168
169
except IndexError :
169
170
res = requests .post (liveconfig_opt )
170
171
if res .status_code != 200 :
@@ -173,7 +174,7 @@ def get_liveconfig_producer(self):
173
174
d = res .json ()
174
175
config = dict (addr = d ["email" ], mail_pw = d ["password" ])
175
176
print ("newtmpuser {}: addr={}" .format (index , config ["addr" ]))
176
- configlist .append (config )
177
+ self . _configlist .append (config )
177
178
yield config
178
179
pytest .fail ("more than {} live accounts requested." .format (MAX_LIVE_CREATED_ACCOUNTS ))
179
180
@@ -217,10 +218,11 @@ class ACSetup:
217
218
CONFIGURED = "CONFIGURED"
218
219
IDLEREADY = "IDLEREADY"
219
220
220
- def __init__ (self , init_time ):
221
+ def __init__ (self , testprocess , init_time ):
221
222
self ._configured_events = Queue ()
222
223
self ._account2state = {}
223
224
self ._imap_cleaned = set ()
225
+ self .testprocess = testprocess
224
226
self .init_time = init_time
225
227
226
228
def start_configure (self , account , reconfigure = False ):
@@ -242,7 +244,8 @@ def wait_one_configured(self, account):
242
244
acc = self ._pop_config_success ()
243
245
if acc == account :
244
246
break
245
- self .init_direct_imap_and_logging (acc )
247
+ self .init_imap (acc )
248
+ self .init_logging (acc )
246
249
acc ._evtracker .consume_events ()
247
250
248
251
def bring_online (self ):
@@ -272,25 +275,24 @@ def _pop_config_success(self):
272
275
return acc
273
276
274
277
def _onconfigure_start_io (self , acc ):
278
+ self .init_imap (acc )
279
+ self .init_logging (acc )
275
280
acc .start_io ()
276
281
print (acc ._logid , "waiting for inbox IDLE to become ready" )
277
282
acc ._evtracker .wait_idle_inbox_ready ()
278
- self .init_direct_imap_and_logging (acc )
279
283
acc ._evtracker .consume_events ()
280
284
acc .log ("inbox IDLE ready" )
281
285
282
- def init_direct_imap_and_logging (self , acc ):
283
- """ idempotent function for initializing direct_imap and logging for an account. """
284
- self .init_direct_imap (acc )
285
- self .init_logging (acc )
286
-
287
286
def init_logging (self , acc ):
287
+ """ idempotent function for initializing logging (will replace existing logger). """
288
288
logger = FFIEventLogger (acc , logid = acc ._logid , init_time = self .init_time )
289
- acc .add_account_plugin (logger , name = acc ._logid )
289
+ acc .add_account_plugin (logger , name = "logger-" + acc ._logid )
290
290
291
- def init_direct_imap (self , acc ):
292
- """ idempotent function for initializing direct_imap. """
291
+ def init_imap (self , acc ):
292
+ """ initialize direct_imap and cleanup server state. """
293
293
from deltachat .direct_imap import DirectImap
294
+
295
+ assert acc .is_configured ()
294
296
if not hasattr (acc , "direct_imap" ):
295
297
acc .direct_imap = DirectImap (acc )
296
298
addr = acc .get_config ("addr" )
@@ -315,11 +317,12 @@ def __init__(self, request, testprocess, tmpdir, data) -> None:
315
317
self .tmpdir = tmpdir
316
318
self .pytestconfig = request .config
317
319
self .data = data
320
+ self .testprocess = testprocess
318
321
self ._liveconfig_producer = testprocess .get_liveconfig_producer ()
319
322
320
323
self ._finalizers = []
321
324
self ._accounts = []
322
- self ._acsetup = ACSetup (self .init_time )
325
+ self ._acsetup = ACSetup (testprocess , self .init_time )
323
326
self ._preconfigured_keys = ["alice" , "bob" , "charlie" ,
324
327
"dom" , "elena" , "fiona" ]
325
328
self .set_logging_default (False )
@@ -344,7 +347,7 @@ def get_next_liveconfig(self):
344
347
""" Base function to get functional online configurations
345
348
where we can make valid SMTP and IMAP connections with.
346
349
"""
347
- configdict = next (self ._liveconfig_producer )
350
+ configdict = next (self ._liveconfig_producer ). copy ()
348
351
if "e2ee_enabled" not in configdict :
349
352
configdict ["e2ee_enabled" ] = "1"
350
353
@@ -480,10 +483,6 @@ def dump_imap_summary(self, logfile):
480
483
ac .dump_account_info (logfile = logfile )
481
484
imap = getattr (ac , "direct_imap" , None )
482
485
if imap is not None :
483
- try :
484
- imap .idle_done ()
485
- except Exception :
486
- pass
487
486
imap .dump_imap_structures (self .tmpdir , logfile = logfile )
488
487
489
488
def get_accepted_chat (self , ac1 : Account , ac2 : Account ):
@@ -501,6 +500,7 @@ def introduce_each_other(self, accounts, sending=True):
501
500
acc2 .create_chat (acc ).send_text ("hi back" )
502
501
to_wait .append (acc )
503
502
for acc in to_wait :
503
+ acc .log ("waiting for incoming message" )
504
504
acc ._evtracker .wait_next_incoming_message ()
505
505
506
506
0 commit comments