Skip to content

Commit ea54446

Browse files
author
Menno Smits
committed
CONDSTORE live test is now more reliable
... especially on Gmail. Don't assume that adding a message will increment the MODSEQ by just 1. Fixes mjs#129. --HG-- branch : stable
1 parent 5a96318 commit ea54446

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

NEWS.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ called datetime_to_INTERNALDATE. This will only affect you in the
3131
unlikely case that you were importing this function out of the
3232
IMAPClient package.
3333

34-
Documentation Updates
35-
---------------------
36-
The docs for various IMAPClient methods, and the HACKING.rst file have
37-
been updated.
34+
Other
35+
-----
36+
* The docs for various IMAPClient methods, and the HACKING.rst file
37+
have been updated.
38+
* CONDSTORE live test is now more reliable (especially when running
39+
against Gmail)
3840

3941
======
4042
0.12

imapclient/livetest.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,15 +739,26 @@ def test_fetch_modifiers(self):
739739
self.client.close_folder()
740740
self.clear_folder(self.base_folder)
741741

742+
#
742743
# Actual testing starts here
743-
maxModSeq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
744+
#
745+
746+
# Get the starting MODSEQ
747+
modseq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
748+
749+
# Add a message so that the MODSEQ gets bumped
744750
self.append_msg(SIMPLE_MESSAGE)
745751
msg_id = self.client.search()[0]
746-
resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % maxModSeq])
747-
self.assertIn(b'MODSEQ', resp[msg_id])
748752

749-
# Prove that the modifier is actually being used
750-
resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % (maxModSeq + 1)])
753+
# Request changes since the starting MODSEQ: this should
754+
# return the new message.
755+
resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % modseq])
756+
new_modseq = resp[msg_id][b"MODSEQ"][0]
757+
self.assertGreater(new_modseq, modseq)
758+
759+
# Now asked for changes since the MODSEQ on the added
760+
# message. These shouldn't be any.
761+
resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % new_modseq])
751762
self.assertEqual(resp, {})
752763

753764
def test_BODYSTRUCTURE(self):

0 commit comments

Comments
 (0)