mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
address on flub comment, start on autocryt transfer test
This commit is contained in:
@@ -305,6 +305,12 @@ class Account(object):
|
||||
lib.dc_perform_imap_jobs(self._dc_context)
|
||||
self._imex_completed.wait()
|
||||
|
||||
def initiate_key_transfer(self):
|
||||
"""initiate Autocrypt key transfer by sending a self-sent message.
|
||||
|
||||
"""
|
||||
return from_dc_charpointer(lib.dc_initiate_key_transfer(self._dc_context))
|
||||
|
||||
def start_threads(self):
|
||||
""" start IMAP/SMTP threads (and configure account if it hasn't happened).
|
||||
|
||||
@@ -317,6 +323,7 @@ class Account(object):
|
||||
|
||||
def stop_threads(self):
|
||||
""" stop IMAP/SMTP threads. """
|
||||
lib.dc_stop_ongoing_process(self._dc_context)
|
||||
self._threads.stop(wait=True)
|
||||
|
||||
def _process_event(self, ctx, evt_name, data1, data2):
|
||||
@@ -362,14 +369,12 @@ class IOThreads:
|
||||
thread.join()
|
||||
|
||||
def imap_thread_run(self):
|
||||
print("starting imap thread")
|
||||
while not self._thread_quitflag:
|
||||
lib.dc_perform_imap_jobs(self._dc_context)
|
||||
lib.dc_perform_imap_fetch(self._dc_context)
|
||||
lib.dc_perform_imap_idle(self._dc_context)
|
||||
|
||||
def smtp_thread_run(self):
|
||||
print("starting smtp thread")
|
||||
while not self._thread_quitflag:
|
||||
lib.dc_perform_smtp_jobs(self._dc_context)
|
||||
lib.dc_perform_smtp_idle(self._dc_context)
|
||||
|
||||
@@ -93,6 +93,10 @@ class Message(object):
|
||||
"""
|
||||
return MessageType(lib.dc_msg_get_viewtype(self._dc_msg))
|
||||
|
||||
def is_setup_message(self):
|
||||
""" return True if this message is a setup message. """
|
||||
return lib.dc_is_setupmessage(self._dc_msg)
|
||||
|
||||
@props.with_doc
|
||||
def time_sent(self):
|
||||
"""UTC time when the message was sent.
|
||||
@@ -198,6 +202,7 @@ class MessageType(object):
|
||||
return self._type == const.DC_MSG_FILE
|
||||
|
||||
|
||||
|
||||
@attr.s
|
||||
class MessageState(object):
|
||||
""" Current Message In/Out state, updated on each call of is_* methods.
|
||||
|
||||
@@ -106,6 +106,17 @@ def acfactory(pytestconfig, tmpdir, request):
|
||||
self._finalizers.append(ac.stop_threads)
|
||||
return ac
|
||||
|
||||
def clone_online_account(self, account):
|
||||
self.live_count += 1
|
||||
tmpdb = tmpdir.join("livedb%d" % self.live_count)
|
||||
ac = Account(tmpdb.strpath, logid="ac{}".format(self.live_count))
|
||||
ac._evlogger.init_time = self.init_time
|
||||
ac._evlogger.set_timeout(30)
|
||||
ac.configure(addr=account.get_config("addr"), mail_pw=account.get_config("mail_pw"))
|
||||
ac.start_threads()
|
||||
self._finalizers.append(ac.stop_threads)
|
||||
return ac
|
||||
|
||||
return AccountMaker()
|
||||
|
||||
|
||||
|
||||
@@ -441,3 +441,15 @@ class TestOnlineAccount:
|
||||
messages = chat2.get_messages()
|
||||
assert len(messages) == 1
|
||||
assert messages[0].text == "msg1"
|
||||
|
||||
def test_ac_setup(self, acfactory):
|
||||
ac1 = acfactory.get_online_configuring_account()
|
||||
wait_configuration_progress(ac1, 1000)
|
||||
setup_code = ac1.initiate_key_transfer()
|
||||
ac2 = acfactory.clone_online_account(ac1)
|
||||
wait_configuration_progress(ac2, 1000)
|
||||
ac2._timeout = 10
|
||||
ev = ac2._evlogger.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED")
|
||||
msg = ac2.get_message_by_id(ev[2])
|
||||
assert msg.is_setup_message()
|
||||
assert 0, setup_code
|
||||
|
||||
Reference in New Issue
Block a user