Syncing strategy

Sebastian Spaeth Sebastian at SSpaeth.de
Thu Dec 9 18:54:13 UTC 2010


On Thu, 9 Dec 2010 19:28:53 +0100, Nicolas Sebrecht <nicolas.s-dev at laposte.net> wrote:
> On Thu, Dec 09, 2010 at 11:07:07AM +0100, Sebastian Spaeth wrote:
> > 
> > But I will be more confident in making changes to the sync strategy once
> > I have a basic test suite up.
> 
> I have no idea where you are in the test suites but you certainly should
> send your patches very soon. I mean at a very early state so that we
> all can help/review the core design. It would be really sad to break a
> lot of work because of some design improvements.
> 
> Release soon, release often. ,-)

Well, I cannot let this one go without response...

"test suite" is quite a mouth full so far :-). 

my offlineimap fork on github (git at github.com:spaetz/offlineimap.git)
has a feature/testsuite branch that contains it. 

Or download via http, it is essentially a single file test.py in a
top-level tests directory:

https://github.com/spaetz/offlineimap/tree/feature%2Ftestsuite/tests

The code is still undocumented as absolute work in progress and things
are being shuffled around still.

What the plan is:

-Use python's unittest (as that comes included)

There is a class:
class Folder2FolderScaffold

which is responsible for creating a fake configure object, setting up 2
maildirs in a /tmp dir, providing a "putmail" function for creating new
mails and deleteing everything after the tests are done.

Then the class TestOfflineImapFunctions(unittest.TestCase):

contains the actual test cases. Currently there are 2 test cases.


1) Sets up two maildirs, copies a message into one and syncs in the same way that offlineimap
usually syncs. The test succeeds if it ends up with the same message in
both Maildirs afterwards.

2) it resyncs without having changed anything, and checks that nothing
has changed afterwards.

There are plenty more conditions that we want to test of course.


So far so good.. The dificulties:
 - Offlineimap does not support Maildir2Maildir syncing using the
   high-level functionality. I understand this is due to the
   impossibility of doing IMAP<->Maildir1<->Maildir2<->IMAP2 (because of
   different UIDs being assigned to the messages by the servers). But
   for testing purposes that hurts me. And I will propose patches to
   make that easier. But that is not urgent.

- I want to create the Maildir Scaffold *once* when i start maildir
  tests and rip it down after all the tests have run. However, the
  TestCase class runs setUp() and tearDown() for each single test,
  making it unsuitable. It also runs testCase.__init__ and __del__ for
  each test, making that unusable too. What I need and what are the
  TestCase.setUpClass() and tearDownClass() functions, which are run
  exactly once at the beginning and the end of all tests in a TestCase.
  However, that is only available on python 2.7. :-(.

  So I fudge now and call test2 at the end of test1, which let's
  everything appear as a single case. This needs to be investigated how
  it can be solved in a neat way.

- No tests yet involving *real* IMAP dirs, however as the sync logic is
  the same indepeding on the backend, 2 maildirs let me find sync logic
  errors, at least.
  The scaffold classes need to be taught to also work with a test IMAP
  account, I guess.

Plus I lost the motivation for a while, but I will pick up on it
again. I'd be willing to receive help and patches though :). *hint hint*

Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/offlineimap-project/attachments/20101209/7cf0efc5/attachment.pgp>


More information about the OfflineIMAP-project mailing list