Refine Python CI

Add lint environment to `deltachat-rpc-client/`
and set line length to 120, same as in `python/`.

Switch from flake8 to ruff.

Fix ruff warnings.
This commit is contained in:
link2xt
2023-01-19 00:31:39 +00:00
parent ef6f252842
commit fac7b064b4
41 changed files with 312 additions and 345 deletions

View File

@@ -36,7 +36,8 @@ register_global_plugin(events)
def run_cmdline(argv=None, account_plugins=None):
"""Run a simple default command line app, registering the specified
account plugins."""
account plugins.
"""
import argparse
if argv is None:

View File

@@ -102,8 +102,8 @@ def find_header(flags):
printf("%s", _dc_header_file_location());
return 0;
}
"""
)
""",
),
)
cwd = os.getcwd()
try:
@@ -198,7 +198,7 @@ def ffibuilder():
typedef int... time_t;
void free(void *ptr);
extern int dc_event_has_string_data(int);
"""
""",
)
function_defs = extract_functions(flags)
defines = extract_defines(flags)

View File

@@ -1,4 +1,4 @@
""" Account class implementation. """
"""Account class implementation."""
from __future__ import print_function
@@ -39,7 +39,7 @@ def get_core_info():
ffi.gc(
lib.dc_context_new(as_dc_charpointer(""), as_dc_charpointer(path.name), ffi.NULL),
lib.dc_context_unref,
)
),
)
@@ -172,10 +172,7 @@ class Account(object):
namebytes = name.encode("utf8")
if isinstance(value, (int, bool)):
value = str(int(value))
if value is not None:
valuebytes = value.encode("utf8")
else:
valuebytes = ffi.NULL
valuebytes = value.encode("utf8") if value is not None else ffi.NULL
lib.dc_set_config(self._dc_context, namebytes, valuebytes)
def get_config(self, name: str) -> str:
@@ -225,9 +222,10 @@ class Account(object):
return bool(lib.dc_is_configured(self._dc_context))
def is_open(self) -> bool:
"""Determine if account is open
"""Determine if account is open.
:returns True if account is open."""
:returns True if account is open.
"""
return bool(lib.dc_context_is_open(self._dc_context))
def set_avatar(self, img_path: Optional[str]) -> None:
@@ -543,7 +541,7 @@ class Account(object):
return from_dc_charpointer(res)
def check_qr(self, qr):
"""check qr code and return :class:`ScannedQRCode` instance representing the result"""
"""check qr code and return :class:`ScannedQRCode` instance representing the result."""
res = ffi.gc(lib.dc_check_qr(self._dc_context, as_dc_charpointer(qr)), lib.dc_lot_unref)
lot = DCLot(res)
if lot.state() == const.DC_QR_ERROR:
@@ -662,7 +660,7 @@ class Account(object):
return lib.dc_all_work_done(self._dc_context)
def start_io(self):
"""start this account's IO scheduling (Rust-core async scheduler)
"""start this account's IO scheduling (Rust-core async scheduler).
If this account is not configured an Exception is raised.
You need to call account.configure() and account.wait_configure_finish()
@@ -705,12 +703,10 @@ class Account(object):
"""
lib.dc_maybe_network(self._dc_context)
def configure(self, reconfigure: bool = False) -> ConfigureTracker:
def configure(self) -> ConfigureTracker:
"""Start configuration process and return a Configtracker instance
on which you can block with wait_finish() to get a True/False success
value for the configuration process.
:param reconfigure: deprecated, doesn't need to be checked anymore.
"""
if not self.get_config("addr") or not self.get_config("mail_pw"):
raise MissingCredentials("addr or mail_pwd not set in config")
@@ -733,7 +729,8 @@ class Account(object):
def shutdown(self) -> None:
"""shutdown and destroy account (stop callback thread, close and remove
underlying dc_context)."""
underlying dc_context).
"""
if self._dc_context is None:
return

View File

@@ -1,4 +1,4 @@
""" Chat and Location related API. """
"""Chat and Location related API."""
import calendar
import json
@@ -37,7 +37,7 @@ class Chat(object):
return self.id == getattr(other, "id", None) and self.account._dc_context == other.account._dc_context
def __ne__(self, other) -> bool:
return not (self == other)
return not self == other
def __repr__(self) -> str:
return "<Chat id={} name={}>".format(self.id, self.get_name())
@@ -74,19 +74,19 @@ class Chat(object):
return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_GROUP
def is_single(self) -> bool:
"""Return True if this chat is a single/direct chat, False otherwise"""
"""Return True if this chat is a single/direct chat, False otherwise."""
return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_SINGLE
def is_mailinglist(self) -> bool:
"""Return True if this chat is a mailing list, False otherwise"""
"""Return True if this chat is a mailing list, False otherwise."""
return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_MAILINGLIST
def is_broadcast(self) -> bool:
"""Return True if this chat is a broadcast list, False otherwise"""
"""Return True if this chat is a broadcast list, False otherwise."""
return lib.dc_chat_get_type(self._dc_chat) == const.DC_CHAT_TYPE_BROADCAST
def is_multiuser(self) -> bool:
"""Return True if this chat is a multi-user chat (group, mailing list or broadcast), False otherwise"""
"""Return True if this chat is a multi-user chat (group, mailing list or broadcast), False otherwise."""
return lib.dc_chat_get_type(self._dc_chat) in (
const.DC_CHAT_TYPE_GROUP,
const.DC_CHAT_TYPE_MAILINGLIST,
@@ -94,11 +94,11 @@ class Chat(object):
)
def is_self_talk(self) -> bool:
"""Return True if this chat is the self-chat (a.k.a. "Saved Messages"), False otherwise"""
"""Return True if this chat is the self-chat (a.k.a. "Saved Messages"), False otherwise."""
return bool(lib.dc_chat_is_self_talk(self._dc_chat))
def is_device_talk(self) -> bool:
"""Returns True if this chat is the "Device Messages" chat, False otherwise"""
"""Returns True if this chat is the "Device Messages" chat, False otherwise."""
return bool(lib.dc_chat_is_device_talk(self._dc_chat))
def is_muted(self) -> bool:
@@ -109,12 +109,12 @@ class Chat(object):
return bool(lib.dc_chat_is_muted(self._dc_chat))
def is_pinned(self) -> bool:
"""Return True if this chat is pinned, False otherwise"""
"""Return True if this chat is pinned, False otherwise."""
return lib.dc_chat_get_visibility(self._dc_chat) == const.DC_CHAT_VISIBILITY_PINNED
def is_archived(self) -> bool:
"""Return True if this chat is archived, False otherwise.
:returns: True if archived, False otherwise
:returns: True if archived, False otherwise.
"""
return lib.dc_chat_get_visibility(self._dc_chat) == const.DC_CHAT_VISIBILITY_ARCHIVED
@@ -136,7 +136,7 @@ class Chat(object):
def can_send(self) -> bool:
"""Check if messages can be sent to a give chat.
This is not true eg. for the contact requests or for the device-talk
This is not true eg. for the contact requests or for the device-talk.
:returns: True if the chat is writable, False otherwise
"""
@@ -167,7 +167,7 @@ class Chat(object):
def get_color(self):
"""return the color of the chat.
:returns: color as 0x00rrggbb
:returns: color as 0x00rrggbb.
"""
return lib.dc_chat_get_color(self._dc_chat)
@@ -178,21 +178,18 @@ class Chat(object):
return json.loads(s)
def mute(self, duration: Optional[int] = None) -> None:
"""mutes the chat
"""mutes the chat.
:param duration: Number of seconds to mute the chat for. None to mute until unmuted again.
:returns: None
"""
if duration is None:
mute_duration = -1
else:
mute_duration = duration
mute_duration = -1 if duration is None else duration
ret = lib.dc_set_chat_mute_duration(self.account._dc_context, self.id, mute_duration)
if not bool(ret):
raise ValueError("Call to dc_set_chat_mute_duration failed")
def unmute(self) -> None:
"""unmutes the chat
"""unmutes the chat.
:returns: None
"""
@@ -252,7 +249,8 @@ class Chat(object):
def get_encryption_info(self) -> Optional[str]:
"""Return encryption info for this chat.
:returns: a string with encryption preferences of all chat members"""
:returns: a string with encryption preferences of all chat members
"""
res = lib.dc_get_chat_encrinfo(self.account._dc_context, self.id)
return from_dc_charpointer(res)
@@ -463,7 +461,7 @@ class Chat(object):
def get_contacts(self):
"""get all contacts for this chat.
:returns: list of :class:`deltachat.contact.Contact` objects for this chat
:returns: list of :class:`deltachat.contact.Contact` objects for this chat.
"""
from .contact import Contact
@@ -547,19 +545,10 @@ class Chat(object):
:param timespan_to: a datetime object or None (indicating up till now)
:returns: list of :class:`deltachat.chat.Location` objects.
"""
if timestamp_from is None:
time_from = 0
else:
time_from = calendar.timegm(timestamp_from.utctimetuple())
if timestamp_to is None:
time_to = 0
else:
time_to = calendar.timegm(timestamp_to.utctimetuple())
time_from = 0 if timestamp_from is None else calendar.timegm(timestamp_from.utctimetuple())
time_to = 0 if timestamp_to is None else calendar.timegm(timestamp_to.utctimetuple())
if contact is None:
contact_id = 0
else:
contact_id = contact.id
contact_id = 0 if contact is None else contact.id
dc_array = lib.dc_get_locations(self.account._dc_context, self.id, contact_id, time_from, time_to)
return [

View File

@@ -1,4 +1,4 @@
""" Contact object. """
"""Contact object."""
from datetime import date, datetime, timezone
from typing import Optional
@@ -28,7 +28,7 @@ class Contact(object):
return self.account._dc_context == other.account._dc_context and self.id == other.id
def __ne__(self, other):
return not (self == other)
return not self == other
def __repr__(self):
return "<Contact id={} addr={} dc_context={}>".format(self.id, self.addr, self.account._dc_context)
@@ -76,7 +76,7 @@ class Contact(object):
return lib.dc_contact_is_verified(self._dc_contact)
def get_verifier(self, contact):
"""Return the address of the contact that verified the contact"""
"""Return the address of the contact that verified the contact."""
return from_dc_charpointer(lib.dc_contact_get_verifier_addr(contact._dc_contact))
def get_profile_image(self) -> Optional[str]:

View File

@@ -79,15 +79,17 @@ class DirectImap:
def select_config_folder(self, config_name: str):
"""Return info about selected folder if it is
configured, otherwise None."""
configured, otherwise None.
"""
if "_" not in config_name:
config_name = "configured_{}_folder".format(config_name)
foldername = self.account.get_config(config_name)
if foldername:
return self.select_folder(foldername)
return None
def list_folders(self) -> List[str]:
"""return list of all existing folder names"""
"""return list of all existing folder names."""
assert not self._idling
return [folder.name for folder in self.conn.folder.list()]
@@ -103,7 +105,7 @@ class DirectImap:
def get_all_messages(self) -> List[MailMessage]:
assert not self._idling
return [mail for mail in self.conn.fetch()]
return list(self.conn.fetch())
def get_unread_messages(self) -> List[str]:
assert not self._idling
@@ -221,5 +223,4 @@ class IdleManager:
def done(self):
"""send idle-done to server if we are currently in idle mode."""
res = self.direct_imap.conn.idle.stop()
return res
return self.direct_imap.conn.idle.stop()

View File

@@ -32,12 +32,11 @@ class FFIEvent:
def __str__(self):
if self.name == "DC_EVENT_INFO":
return "INFO {data2}".format(data2=self.data2)
elif self.name == "DC_EVENT_WARNING":
if self.name == "DC_EVENT_WARNING":
return "WARNING {data2}".format(data2=self.data2)
elif self.name == "DC_EVENT_ERROR":
if self.name == "DC_EVENT_ERROR":
return "ERROR {data2}".format(data2=self.data2)
else:
return "{name} data1={data1} data2={data2}".format(**self.__dict__)
return "{name} data1={data1} data2={data2}".format(**self.__dict__)
class FFIEventLogger:
@@ -135,7 +134,8 @@ class FFIEventTracker:
def wait_for_connectivity(self, connectivity):
"""Wait for the specified connectivity.
This only works reliably if the connectivity doesn't change
again too quickly, otherwise we might miss it."""
again too quickly, otherwise we might miss it.
"""
while 1:
if self.account.get_connectivity() == connectivity:
return
@@ -143,12 +143,13 @@ class FFIEventTracker:
def wait_for_connectivity_change(self, previous, expected_next):
"""Wait until the connectivity changes to `expected_next`.
Fails the test if it changes to something else."""
Fails the test if it changes to something else.
"""
while 1:
current = self.account.get_connectivity()
if current == expected_next:
return
elif current != previous:
if current != previous:
raise Exception("Expected connectivity " + str(expected_next) + " but got " + str(current))
self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")
@@ -183,7 +184,8 @@ class FFIEventTracker:
- ac1 and ac2 are created
- ac1 sends a message to ac2
- ac2 is still running FetchExsistingMsgs job and thinks it's an existing, old message
- therefore no DC_EVENT_INCOMING_MSG is sent"""
- therefore no DC_EVENT_INCOMING_MSG is sent
"""
self.get_info_contains("INBOX: Idle entering")
def wait_next_incoming_message(self):
@@ -193,14 +195,15 @@ class FFIEventTracker:
def wait_next_messages_changed(self):
"""wait for and return next message-changed message or None
if the event contains no msgid"""
if the event contains no msgid
"""
ev = self.get_matching("DC_EVENT_MSGS_CHANGED")
if ev.data2 > 0:
return self.account.get_message_by_id(ev.data2)
return None
def wait_next_reactions_changed(self):
"""wait for and return next reactions-changed message"""
"""wait for and return next reactions-changed message."""
ev = self.get_matching("DC_EVENT_REACTIONS_CHANGED")
assert ev.data1 > 0
return self.account.get_message_by_id(ev.data2)
@@ -292,10 +295,10 @@ class EventThread(threading.Thread):
if data1 == 0 or data1 == 1000:
success = data1 == 1000
comment = ffi_event.data2
yield "ac_configure_completed", dict(success=success, comment=comment)
yield "ac_configure_completed", {"success": success, "comment": comment}
elif name == "DC_EVENT_INCOMING_MSG":
msg = account.get_message_by_id(ffi_event.data2)
yield map_system_message(msg) or ("ac_incoming_message", dict(message=msg))
yield map_system_message(msg) or ("ac_incoming_message", {"message": msg})
elif name == "DC_EVENT_MSGS_CHANGED":
if ffi_event.data2 != 0:
msg = account.get_message_by_id(ffi_event.data2)
@@ -303,19 +306,19 @@ class EventThread(threading.Thread):
res = map_system_message(msg)
if res and res[0].startswith("ac_member"):
yield res
yield "ac_outgoing_message", dict(message=msg)
yield "ac_outgoing_message", {"message": msg}
elif msg.is_in_fresh():
yield map_system_message(msg) or (
"ac_incoming_message",
dict(message=msg),
{"message": msg},
)
elif name == "DC_EVENT_REACTIONS_CHANGED":
assert ffi_event.data1 > 0
msg = account.get_message_by_id(ffi_event.data2)
yield "ac_reactions_changed", dict(message=msg)
yield "ac_reactions_changed", {"message": msg}
elif name == "DC_EVENT_MSG_DELIVERED":
msg = account.get_message_by_id(ffi_event.data2)
yield "ac_message_delivered", dict(message=msg)
yield "ac_message_delivered", {"message": msg}
elif name == "DC_EVENT_CHAT_MODIFIED":
chat = account.get_chat_by_id(ffi_event.data1)
yield "ac_chat_modified", dict(chat=chat)
yield "ac_chat_modified", {"chat": chat}

View File

@@ -1,4 +1,4 @@
""" Hooks for Python bindings to Delta Chat Core Rust CFFI"""
"""Hooks for Python bindings to Delta Chat Core Rust CFFI."""
import pluggy

View File

@@ -1,4 +1,4 @@
""" The Message object. """
"""The Message object."""
import json
import os
@@ -59,10 +59,7 @@ class Message(object):
:param view_type: the message type code or one of the strings:
"text", "audio", "video", "file", "sticker", "videochat", "webxdc"
"""
if isinstance(view_type, int):
view_type_code = view_type
else:
view_type_code = get_viewtype_code_from_name(view_type)
view_type_code = view_type if isinstance(view_type, int) else get_viewtype_code_from_name(view_type)
return Message(
account,
ffi.gc(lib.dc_msg_new(account._dc_context, view_type_code), lib.dc_msg_unref),
@@ -129,7 +126,7 @@ class Message(object):
@props.with_doc
def filemime(self) -> str:
"""mime type of the file (if it exists)"""
"""mime type of the file (if it exists)."""
return from_dc_charpointer(lib.dc_msg_get_filemime(self._dc_msg))
def get_status_updates(self, serial: int = 0) -> list:
@@ -141,7 +138,7 @@ class Message(object):
:param serial: The last known serial. Pass 0 if there are no known serials to receive all updates.
"""
return json.loads(
from_dc_charpointer(lib.dc_get_webxdc_status_updates(self.account._dc_context, self.id, serial))
from_dc_charpointer(lib.dc_get_webxdc_status_updates(self.account._dc_context, self.id, serial)),
)
def send_status_update(self, json_data: Union[str, dict], description: str) -> bool:
@@ -158,8 +155,11 @@ class Message(object):
json_data = json.dumps(json_data, default=str)
return bool(
lib.dc_send_webxdc_status_update(
self.account._dc_context, self.id, as_dc_charpointer(json_data), as_dc_charpointer(description)
)
self.account._dc_context,
self.id,
as_dc_charpointer(json_data),
as_dc_charpointer(description),
),
)
def send_reaction(self, reaction: str):
@@ -232,16 +232,18 @@ class Message(object):
ts = lib.dc_msg_get_received_timestamp(self._dc_msg)
if ts:
return datetime.fromtimestamp(ts, timezone.utc)
return None
@props.with_doc
def ephemeral_timer(self):
"""Ephemeral timer in seconds
"""Ephemeral timer in seconds.
:returns: timer in seconds or None if there is no timer
"""
timer = lib.dc_msg_get_ephemeral_timer(self._dc_msg)
if timer:
return timer
return None
@props.with_doc
def ephemeral_timestamp(self):
@@ -255,23 +257,25 @@ class Message(object):
@property
def quoted_text(self) -> Optional[str]:
"""Text inside the quote
"""Text inside the quote.
:returns: Quoted text"""
:returns: Quoted text
"""
return from_optional_dc_charpointer(lib.dc_msg_get_quoted_text(self._dc_msg))
@property
def quote(self):
"""Quote getter
"""Quote getter.
:returns: Quoted message, if found in the database"""
:returns: Quoted message, if found in the database
"""
msg = lib.dc_msg_get_quoted_msg(self._dc_msg)
if msg:
return Message(self.account, ffi.gc(msg, lib.dc_msg_unref))
@quote.setter
def quote(self, quoted_message):
"""Quote setter"""
"""Quote setter."""
lib.dc_msg_set_quote(self._dc_msg, quoted_message._dc_msg)
def force_plaintext(self) -> None:
@@ -286,7 +290,7 @@ class Message(object):
:returns: email-mime message object (with headers only, no body).
"""
import email.parser
import email
mime_headers = lib.dc_get_mime_headers(self.account._dc_context, self.id)
if mime_headers:
@@ -297,7 +301,7 @@ class Message(object):
@property
def error(self) -> Optional[str]:
"""Error message"""
"""Error message."""
return from_optional_dc_charpointer(lib.dc_msg_get_error(self._dc_msg))
@property
@@ -493,7 +497,8 @@ def get_viewtype_code_from_name(view_type_name):
if code is not None:
return code
raise ValueError(
"message typecode not found for {!r}, " "available {!r}".format(view_type_name, list(_view_type_mapping.keys()))
"message typecode not found for {!r}, "
"available {!r}".format(view_type_name, list(_view_type_mapping.keys())),
)
@@ -506,14 +511,11 @@ def map_system_message(msg):
if msg.is_system_message():
res = parse_system_add_remove(msg.text)
if not res:
return
return None
action, affected, actor = res
affected = msg.account.get_contact_by_addr(affected)
if actor == "me":
actor = None
else:
actor = msg.account.get_contact_by_addr(actor)
d = dict(chat=msg.chat, contact=affected, actor=actor, message=msg)
actor = None if actor == "me" else msg.account.get_contact_by_addr(actor)
d = {"chat": msg.chat, "contact": affected, "actor": actor, "message": msg}
return "ac_member_" + res[0], d
@@ -528,8 +530,8 @@ def extract_addr(text):
def parse_system_add_remove(text):
"""return add/remove info from parsing the given system message text.
returns a (action, affected, actor) triple"""
returns a (action, affected, actor) triple
"""
# You removed member a@b.
# You added member a@b.
# Member Me (x@y) removed by a@b.

View File

@@ -8,7 +8,7 @@ def with_doc(f):
# copied over unmodified from
# https://github.com/devpi/devpi/blob/master/common/devpi_common/types.py
def cached(f):
"""returns a cached property that is calculated by function f"""
"""returns a cached property that is calculated by function f."""
def get(self):
try:
@@ -17,8 +17,9 @@ def cached(f):
self._property_cache = {}
except KeyError:
pass
x = self._property_cache[f] = f(self)
return x
res = f(self)
self._property_cache[f] = res
return res
def set(self, val):
propcache = self.__dict__.setdefault("_property_cache", {})

View File

@@ -9,7 +9,8 @@ class ProviderNotFoundError(Exception):
class Provider(object):
"""Provider information.
"""
Provider information.
:param domain: The email to get the provider info for.
"""

View File

@@ -1,4 +1,4 @@
""" The Reactions object. """
"""The Reactions object."""
from .capi import ffi, lib
from .cutil import from_dc_charpointer, iter_array

View File

@@ -29,7 +29,7 @@ def pytest_addoption(parser):
"--liveconfig",
action="store",
default=None,
help="a file with >=2 lines where each line " "contains NAME=VALUE config settings for one account",
help="a file with >=2 lines where each line contains NAME=VALUE config settings for one account",
)
group.addoption(
"--ignored",
@@ -124,7 +124,7 @@ def pytest_report_header(config, startdir):
info["deltachat_core_version"],
info["sqlite_version"],
info["journal_mode"],
)
),
]
cfg = config.option.liveconfig
@@ -180,7 +180,7 @@ class TestProcess:
if res.status_code != 200:
pytest.fail("newtmpuser count={} code={}: '{}'".format(index, res.status_code, res.text))
d = res.json()
config = dict(addr=d["email"], mail_pw=d["password"])
config = {"addr": d["email"], "mail_pw": d["password"]}
print("newtmpuser {}: addr={}".format(index, config["addr"]))
self._configlist.append(config)
yield config
@@ -229,7 +229,7 @@ def write_dict_to_dir(dic, target_dir):
path.write_bytes(content)
@pytest.fixture
@pytest.fixture()
def data(request):
class Data:
def __init__(self) -> None:
@@ -253,6 +253,7 @@ def data(request):
if os.path.exists(fn):
return fn
print("WARNING: path does not exist: {!r}".format(fn))
return None
def read_path(self, bn, mode="r"):
fn = self.get_path(bn)
@@ -264,8 +265,11 @@ def data(request):
class ACSetup:
"""accounts setup helper to deal with multiple configure-process
and io & imap initialization phases. From tests, use the higher level
"""
Accounts setup helper to deal with multiple configure-process
and io & imap initialization phases.
From tests, use the higher level
public ACFactory methods instead of its private helper class.
"""
@@ -289,7 +293,7 @@ class ACSetup:
self._account2state[account] = self.CONFIGURED
self.log("added already configured account", account, account.get_config("addr"))
def start_configure(self, account, reconfigure=False):
def start_configure(self, account):
"""add an account and start its configure process."""
class PendingTracker:
@@ -299,7 +303,7 @@ class ACSetup:
account.add_account_plugin(PendingTracker(), name="pending_tracker")
self._account2state[account] = self.CONFIGURING
account.configure(reconfigure=reconfigure)
account.configure()
self.log("started configure on", account)
def wait_one_configured(self, account):
@@ -411,7 +415,8 @@ class ACFactory:
acc.disable_logging()
def get_next_liveconfig(self):
"""Base function to get functional online configurations
"""
Base function to get functional online configurations
where we can make valid SMTP and IMAP connections with.
"""
configdict = next(self._liveconfig_producer).copy()
@@ -465,8 +470,7 @@ class ACFactory:
if fname_pub and fname_sec:
account._preconfigure_keypair(addr, fname_pub, fname_sec)
return True
else:
print("WARN: could not use preconfigured keys for {!r}".format(addr))
print("WARN: could not use preconfigured keys for {!r}".format(addr))
def get_pseudo_configured_account(self, passphrase: Optional[str] = None) -> Account:
# do a pseudo-configured account
@@ -476,14 +480,14 @@ class ACFactory:
acname = ac._logid
addr = "{}@offline.org".format(acname)
ac.update_config(
dict(
addr=addr,
displayname=acname,
mail_pw="123",
configured_addr=addr,
configured_mail_pw="123",
configured="1",
)
{
"addr": addr,
"displayname": acname,
"mail_pw": "123",
"configured_addr": addr,
"configured_mail_pw": "123",
"configured": "1",
},
)
self._preconfigure_key(ac, addr)
self._acsetup.init_logging(ac)
@@ -494,12 +498,12 @@ class ACFactory:
configdict = self.get_next_liveconfig()
else:
# XXX we might want to transfer the key to the new account
configdict = dict(
addr=cloned_from.get_config("addr"),
mail_pw=cloned_from.get_config("mail_pw"),
imap_certificate_checks=cloned_from.get_config("imap_certificate_checks"),
smtp_certificate_checks=cloned_from.get_config("smtp_certificate_checks"),
)
configdict = {
"addr": cloned_from.get_config("addr"),
"mail_pw": cloned_from.get_config("mail_pw"),
"imap_certificate_checks": cloned_from.get_config("imap_certificate_checks"),
"smtp_certificate_checks": cloned_from.get_config("smtp_certificate_checks"),
}
configdict.update(kwargs)
ac = self._get_cached_account(addr=configdict["addr"]) if cache else None
if ac is not None:
@@ -600,7 +604,7 @@ class ACFactory:
acc._evtracker.wait_next_incoming_message()
@pytest.fixture
@pytest.fixture()
def acfactory(request, tmpdir, testprocess, data):
am = ACFactory(request=request, tmpdir=tmpdir, testprocess=testprocess, data=data)
yield am
@@ -665,12 +669,12 @@ class BotProcess:
ignored.append(line)
@pytest.fixture
@pytest.fixture()
def tmp_db_path(tmpdir):
return tmpdir.join("test.db").strpath
@pytest.fixture
@pytest.fixture()
def lp():
class Printer:
def sec(self, msg: str) -> None:

View File

@@ -77,11 +77,11 @@ class ConfigureTracker:
self.account.remove_account_plugin(self)
def wait_smtp_connected(self):
"""wait until smtp is configured."""
"""Wait until SMTP is configured."""
self._smtp_finished.wait()
def wait_imap_connected(self):
"""wait until smtp is configured."""
"""Wait until IMAP is configured."""
self._imap_finished.wait()
def wait_progress(self, data1=None):
@@ -91,7 +91,8 @@ class ConfigureTracker:
break
def wait_finish(self, timeout=None):
"""wait until configure is completed.
"""
Wait until configure is completed.
Raise Exception if Configure failed
"""