-
-
Notifications
You must be signed in to change notification settings - Fork 110
Port folder-related CFFI tests to JSON-RPC #7424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
969b5b7 to
609f30a
Compare
dfa50b2 to
3369598
Compare
| def get_all_messages(self) -> list[MailMessage]: | ||
| assert not self._idling | ||
| return list(self.conn.fetch()) | ||
| return list(self.conn.fetch(mark_seen=False)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imap-tools have a weird default for the FETCH operation, it has mark_seen=True and marks all messages that we fetch with \Seen flag. This is directly in the readme: https://pypi.org/project/imap-tools/
Don't think anyone wants this even outside of tests, it is just a bad API: ikvk/imap_tools#179
| class IdleManager: | ||
| def __init__(self, direct_imap) -> None: | ||
| self.direct_imap = direct_imap | ||
| self.log = direct_imap.account.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
account does not have log, this code got copy-pasted from CFFI bindings. I have removed log references that failed, previously this code was not working at all as nobody used IDLE on direct IMAP with JSON-RPC.
| return res | ||
| return self.direct_imap.conn.idle.poll(timeout=timeout) | ||
|
|
||
| def wait_for_new_message(self, timeout=None) -> bytes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use timeouts anyway, arbitrary timeouts hardcoded in the tests are annoying as they fail when CI runner is paused. We have pytest timout for the whole test in case it gets stuck. Again, this was copy-pasted from CFFI and nobody used it.
3369598 to
13ecfae
Compare
|
This is ready for review. Don't read the commit messages, one of them is even "WIP" inside, I am going to squash the whole thing anyway. |
13ecfae to
e24e218
Compare
iequidoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not easy to review because the code was moved, but as far as i can tell the same scenarios are covered, so looks good to me
e24e218 to
7c072e6
Compare
Created new test_folders.py Moved existing JSON-RPC tests: - test_reactions_for_a_reordering_move - test_delete_deltachat_folder Ported tests: - test_move_works_on_self_sent - test_moved_markseen - test_markseen_message_and_mdn - test_mvbox_thread_and_trash (renamed to test_mvbox_and_trash) - test_scan_folders - test_move_works - test_move_avoids_loop - test_immediate_autodelete - test_trash_multiple_messages The change also contains fixes for direct_imap fixture needed to use IMAP IDLE in JSON-RPC tests.
7c072e6 to
84a9e6c
Compare
Based on #7429
In the "multi-transport" PR #7348 I changed how folder configuration works. We no longer configure folders during the transport configuration, so folders will be configured later. mvbox_move is also disabled during first transport configuration, so enabling mvbox_move should be done after configuring the transport if needed, and then the test needs to wait for the IMAP loop to go idle again so UID validity of mvbox is known. CFFI tests that test folder handling did not do it, so I ported them to JSON-RPC and fixed the issues for all the tests that got broken. CFFI bindings are deprecated anyway and we want to move the tests to JSON-RPC eventually so CFFI bindings can be deleted.
Created new test_folders.py
Moved existing JSON-RPC tests:
Ported tests:
The change also contains fixes for direct_imap fixture
needed to use IMAP IDLE in JSON-RPC tests.