Re: [Mailman-Developers] Implementing the IArchiver
Hi George. Sorry I was on vacation and mostly off-line.
On Aug 06, 2012, at 08:28 PM, George Chatzisofroniou wrote:
I was wondering what is the best way to test an IArchive implementation. Are there any built in test modes that will allow me to send sample messages? I only care about the processing of the messages through my IArchive implementation rather than actually sending them out.
There is an existing test in src/mailman/archiving/tests/test_prototype.py which tests the prototype archiver. It probably does way more than you need though, since it interfaces with the file system. But it should give you a fairly decent idea of how to set up a test for an IArchiver implementation.
A few important things to notice. You'll need to set a layer in the test class. ConfigLayer ensures that the entire ZCA and configuration subsystem is initialized before the test is run; you'll need at least that.
If you do want to send out a sample message, you can use SMTPLayer, which sets up a fake SMTP server and ensures that any email you send through Mailman's delivery system will get delivered to this fake server. Your test can then check that the message arrived and has the contents you expect. If you grep for SMTPLayer, you should find useful examples of that.
See src/mailman/testing/layers.py for the set of existing layers. Their use is a bit funky because of the weird zope.testing semantics (something I want to get rid of eventually). In particular, normal inheritance rules don't apply, which is why you never see upcalls to super(). But that may be detail you don't care about.
I hope that helps. I'm back from vacation now and happy to answer anything else if I can.
Cheers, -Barry
participants (1)
-
Barry Warsaw