]> khamidou — GitHub mirrors - imapclient.git/commitdiff
CONDSTORE live test is now more reliable 0.13
authorMenno Smits <menno@freshfoo.com>
Tue, 30 Jun 2015 09:25:18 +0000 (21:25 +1200)
committerMenno Smits <menno@freshfoo.com>
Tue, 30 Jun 2015 09:25:18 +0000 (21:25 +1200)
... especially on Gmail. Don't assume that adding a message will
increment the MODSEQ by just 1.

Fixes #129.

--HG--
branch : stable

NEWS.rst
imapclient/livetest.py

index d721508fc2ac018d7f73a5e2c243c854a660ac58..4361bd51e0d2a4d6d8247fcfe1df339beebe42a1 100644 (file)
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -31,10 +31,12 @@ called datetime_to_INTERNALDATE. This will only affect you in the
 unlikely case that you were importing this function out of the
 IMAPClient package.
 
-Documentation Updates
----------------------
-The docs for various IMAPClient methods, and the HACKING.rst file have
-been updated.
+Other
+-----
+  * The docs for various IMAPClient methods, and the HACKING.rst file
+    have been updated.
+  * CONDSTORE live test is now more reliable (especially when running
+    against Gmail)
 
 ======
  0.12
index 4797d619e1ae250df4aa6da8cd9370ec79d660da..f8325affb2d6e3d5ad3885f9edaf70d824a65992 100644 (file)
@@ -739,15 +739,26 @@ def createUidTestClass(conf, use_uid):
             self.client.close_folder()
             self.clear_folder(self.base_folder)
 
+            #
             # Actual testing starts here
-            maxModSeq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
+            #
+
+            # Get the starting MODSEQ
+            modseq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
+
+            # Add a message so that the MODSEQ gets bumped
             self.append_msg(SIMPLE_MESSAGE)
             msg_id = self.client.search()[0]
-            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % maxModSeq])
-            self.assertIn(b'MODSEQ', resp[msg_id])
 
-            # Prove that the modifier is actually being used
-            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % (maxModSeq + 1)])
+            # Request changes since the starting MODSEQ: this should
+            # return the new message.
+            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % modseq])
+            new_modseq = resp[msg_id][b"MODSEQ"][0]
+            self.assertGreater(new_modseq, modseq)
+
+            # Now asked for changes since the MODSEQ on the added
+            # message. These shouldn't be any.
+            resp = self.client.fetch(msg_id, ['FLAGS'], ['CHANGEDSINCE %d' % new_modseq])
             self.assertEqual(resp, {})
 
         def test_BODYSTRUCTURE(self):