Skip to content

Commit

Permalink
remove imap_tools from dependencies (#6238)
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez authored Nov 23, 2024
1 parent daeeca3 commit 407bc95
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
3 changes: 2 additions & 1 deletion deltachat-rpc-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 0 additions & 3 deletions deltachat-rpc-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ classifiers = [
"Topic :: Communications :: Email"
]
readme = "README.md"
dependencies = [
"imap-tools",
]

[tool.setuptools.package-data]
deltachat_rpc_client = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Internal Python-level IMAP handling used by the tests.
"""

from __future__ import annotations

import imaplib
Expand All @@ -11,24 +7,20 @@
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"
ALL = "1:*"


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)
Expand Down Expand Up @@ -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
5 changes: 2 additions & 3 deletions deltachat-rpc-client/tests/test_something.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions deltachat-rpc-client/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ deps =
pytest
pytest-timeout
pytest-xdist
imap-tools

[testenv:lint]
skipsdist = True
Expand Down

0 comments on commit 407bc95

Please sign in to comment.