diff --git a/deltachat-rpc-client/README.md b/deltachat-rpc-client/README.md index 52fd83c2cc..9777e06189 100644 --- a/deltachat-rpc-client/README.md +++ b/deltachat-rpc-client/README.md @@ -25,7 +25,8 @@ $ pip install . ## Testing 1. Build `deltachat-rpc-server` with `cargo build -p deltachat-rpc-server`. -2. Run `CHATMAIL_DOMAIN=nine.testrun.org PATH="../target/debug:$PATH" tox`. +2. Install tox `pip install -U tox` +3. Run `CHATMAIL_DOMAIN=nine.testrun.org PATH="../target/debug:$PATH" tox`. Additional arguments to `tox` are passed to pytest, e.g. `tox -- -s` does not capture test output. diff --git a/deltachat-rpc-client/pyproject.toml b/deltachat-rpc-client/pyproject.toml index 3b3c790409..7d02450a56 100644 --- a/deltachat-rpc-client/pyproject.toml +++ b/deltachat-rpc-client/pyproject.toml @@ -24,9 +24,6 @@ classifiers = [ "Topic :: Communications :: Email" ] readme = "README.md" -dependencies = [ - "imap-tools", -] [tool.setuptools.package-data] deltachat_rpc_client = [ diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/direct_imap.py b/deltachat-rpc-client/tests/conftest.py similarity index 96% rename from deltachat-rpc-client/src/deltachat_rpc_client/direct_imap.py rename to deltachat-rpc-client/tests/conftest.py index 196afabae4..bb8ba24e80 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/direct_imap.py +++ b/deltachat-rpc-client/tests/conftest.py @@ -1,7 +1,3 @@ -""" -Internal Python-level IMAP handling used by the tests. -""" - from __future__ import annotations import imaplib @@ -11,17 +7,11 @@ from contextlib import contextmanager from typing import TYPE_CHECKING -from imap_tools import ( - AND, - Header, - MailBox, - MailMessage, - MailMessageFlags, - errors, -) +import pytest +from imap_tools import AND, Header, MailBox, MailMessage, MailMessageFlags, errors if TYPE_CHECKING: - from . import Account + from deltachat_rpc_client import Account FLAGS = b"FLAGS" FETCH = b"FETCH" @@ -29,6 +19,8 @@ class DirectImap: + """Internal Python-level IMAP handling.""" + def __init__(self, account: Account) -> None: self.account = account self.logid = account.get_config("displayname") or id(account) @@ -212,3 +204,8 @@ def wait_for_seen(self, timeout=None) -> int: def done(self): """send idle-done to server if we are currently in idle mode.""" return self.direct_imap.conn.idle.stop() + + +@pytest.fixture +def direct_imap(): + return DirectImap diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index a53e8376ad..cf1d422f29 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -12,7 +12,6 @@ from deltachat_rpc_client import Contact, EventType, Message, events from deltachat_rpc_client.const import DownloadState, MessageState -from deltachat_rpc_client.direct_imap import DirectImap from deltachat_rpc_client.rpc import JsonRpcError @@ -536,7 +535,7 @@ def test_reaction_to_partially_fetched_msg(acfactory, tmp_path): assert list(reactions.reactions_by_contact.values())[0] == [react_str] -def test_reactions_for_a_reordering_move(acfactory): +def test_reactions_for_a_reordering_move(acfactory, direct_imap): """When a batch of messages is moved from Inbox to DeltaChat folder with a single MOVE command, their UIDs may be reordered (e.g. Gmail is known for that) which led to that messages were processed by receive_imf in the wrong order, and, particularly, reactions were processed before @@ -560,7 +559,7 @@ def test_reactions_for_a_reordering_move(acfactory): msg1.send_reaction(react_str).wait_until_delivered() logging.info("moving messages to ac2's DeltaChat folder in the reverse order") - ac2_direct_imap = DirectImap(ac2) + ac2_direct_imap = direct_imap(ac2) ac2_direct_imap.connect() for uid in sorted([m.uid for m in ac2_direct_imap.get_all_messages()], reverse=True): ac2_direct_imap.conn.move(uid, "DeltaChat") diff --git a/deltachat-rpc-client/tox.ini b/deltachat-rpc-client/tox.ini index 843e09c00a..2c3b0cb4ef 100644 --- a/deltachat-rpc-client/tox.ini +++ b/deltachat-rpc-client/tox.ini @@ -16,6 +16,7 @@ deps = pytest pytest-timeout pytest-xdist + imap-tools [testenv:lint] skipsdist = True