lazr.smtptest-2.0.3/0000775000175000017500000000000012452650023014627 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/MANIFEST.in0000664000175000017500000000014112452646674016402 0ustar barrybarry00000000000000include *.py *.txt *.rst MANIFEST.in *.ini recursive-include lazr *.txt *.rst exclude .bzrignore lazr.smtptest-2.0.3/lazr/0000775000175000017500000000000012452650023015577 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr/smtptest/0000775000175000017500000000000012452650023017462 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr/smtptest/server.py0000664000175000017500000001347612452647462021372 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """The SMTP test server.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'QueueServer', 'Server', ] import smtpd import socket import logging import asyncore try: from queue import Empty except ImportError: # Python 2 from Queue import Empty from email import message_from_string COMMASPACE = ', ' log = logging.getLogger('lazr.smtptest') class Channel(smtpd.SMTPChannel): """A channel that can reset the mailbox.""" def __init__(self, server, connection, address): self._server = server smtpd.SMTPChannel.__init__(self, server, connection, address) def smtp_EXIT(self, argument): """EXIT - a new SMTP command to cleanly stop the server.""" self.push('250 Ok') self._server.stop() def smtp_RSET(self, argument): """RSET - hijack this to reset the server instance.""" self._server.reset() smtpd.SMTPChannel.smtp_RSET(self, argument) def send(self, data): """See `SMTPChannel.send()`.""" # Call the base class's send method, but catch all socket errors since # asynchat/asyncore doesn't do it. try: return smtpd.SMTPChannel.send(self, data) except socket.error: # Nothing here can affect the outcome. pass def add_channel(self, map=None): # This has an old style base class. We want to make _map equal to # our server's socket_map, to make this thread safe with other # asyncores. We do it here, overriding the behavior of the asyncore # __init__ as soon as we can, without having to copy over code from # the rest of smtpd.SMTPChannel.__init__ and modify it. if self._map is not self._server.socket_map: self._map = self._server.socket_map smtpd.SMTPChannel.add_channel(self, map) class Server(smtpd.SMTPServer): """An SMTP server.""" def __init__(self, host, port): """Create an SMTP server. :param host: The host name to listen on. :type host: str :param port: The port to listen on. :type port: int """ self.host = host self.port = port self.socket_map = {} smtpd.SMTPServer.__init__(self, (host, port), None) self.set_reuse_addr() log.info('[SMTPServer] listening: %s:%s', host, port) def add_channel(self, map=None): # This has an old style base class. We want to make _map equal to # socket_map, to make this thread safe with other asyncores. We do # it here, overriding the behavior of the SMTPServer __init__ as # soon as we can, without having to copy over code from the rest of # smtpd.SMTPServer.__init__ and modify it. if self._map is not self.socket_map: self._map = self.socket_map smtpd.SMTPServer.add_channel(self, map) def handle_accept(self): """Handle connections by creating our own Channel object.""" connection, address = self.accept() log.info('[SMTPServer] accepted: %s', address) Channel(self, connection, address) def process_message(self, peer, mailfrom, rcpttos, data): """Process a received message.""" log.info('[SMTPServer] processing: %s, %s, %s, size=%s', peer, mailfrom, rcpttos, len(data)) message = message_from_string(data) message['X-Peer'] = '%s:%s' % (peer[0], peer[1]) message['X-MailFrom'] = mailfrom message['X-RcptTo'] = COMMASPACE.join(rcpttos) self.handle_message(message) log.info('[SMTPServer] processed message: %s', message.get('message-id', 'n/a')) def start(self): """Start the asyncore loop.""" log.info('[SMTPServer] starting asyncore loop') asyncore.loop(map=self.socket_map) def stop(self): """Stop the asyncore loop.""" asyncore.close_all(map=self.socket_map) self.close() def reset(self): """Do whatever you need to do on a reset.""" log.info('[SMTPServer] reset') def handle_message(self, message): """Handle the received message. :param message: the completed, parsed received email message. :type message: `email.message.Message` """ pass class QueueServer(Server): """A server which puts messages in a queue.""" def __init__(self, host, port, queue): """Create an SMTP server which puts messages in a queue. :param host: The host name to listen on. :type host: str :param port: The port to listen on. :type port: int :param queue: The queue to put messages in. :type queue: object with a .put() method taking a single message object. """ Server.__init__(self, host, port) self.queue = queue def handle_message(self, message): """See `Server.handle_message()`.""" self.queue.put(message) def reset(self): """See `Server.reset()`.""" while True: try: self.queue.get_nowait() except Empty: break lazr.smtptest-2.0.3/lazr/smtptest/version.txt0000664000175000017500000000000612452647477021727 0ustar barrybarry000000000000002.0.3 lazr.smtptest-2.0.3/lazr/smtptest/controller.py0000664000175000017500000000760012452647415022235 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """The SMTP test controller.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'Controller', 'QueueController', ] import logging import smtplib import threading try: from queue import Empty, Queue except ImportError: # Python 2 from Queue import Empty, Queue from lazr.smtptest.server import QueueServer log = logging.getLogger('lazr.smtptest') class Controller: """The SMTP server controller.""" def __init__(self, server): """The controller of the SMTP server. :param server: The SMTP server to run. The server must have `host` and `port` attributes set. :type server: `lazr.smtptest.server.Server` or subclass """ self._server = server self._thread = threading.Thread(target=server.start) self._thread.daemon = True def _connect(self): """Connect to the SMTP server running in the thread. :return: the connection to the SMTP server :rtype: `smtplib.SMTP` """ smtpd = smtplib.SMTP() smtpd.connect(self._server.host, self._server.port) return smtpd def start(self): """Start the SMTP server in a thread.""" log.info('starting the SMTP server thread') self._thread.start() # Wait until the server is actually responding to clients. log.info('connecting to %s:%s', self._server.host, self._server.port) smtpd = self._connect() response = smtpd.helo('test.localhost') log.info('Got HELO response: %s', response) smtpd.quit() def stop(self): """Stop the smtp server thread.""" log.info('stopping the SMTP server thread') smtpd = self._connect() smtpd.docmd('EXIT') # Wait for the thread to exit. self._thread.join() log.info('SMTP server stopped') def reset(self): """Sent a RSET to the server.""" log.info('resetting the SMTP server.') smtpd = self._connect() smtpd.docmd('RSET') class QueueController(Controller): """An SMTP server controller that coordinates through a queue.""" def __init__(self, host, port): """The controller which coordinates via a Queue. :param host: The host name to listen on. :type host: str :param port: The port to listen on. :type port: int """ self.queue = Queue() self.server = None self._make_server(host, port) super(QueueController, self).__init__(self.server) def _make_server(self, host, port): """Create the server instance, storing it on `self.server`. This interface is non-public; it is for subclasses that need to override server instantiation. :param host: The host name to listen on. :type host: str :param port: The port to listen on. :type port: int """ self.server = QueueServer(host, port, self.queue) def __iter__(self): """Iterate over all the messages in the queue.""" while True: try: yield self.queue.get_nowait() except Empty: raise StopIteration lazr.smtptest-2.0.3/lazr/smtptest/tests/0000775000175000017500000000000012452650023020624 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr/smtptest/tests/__init__.py0000664000175000017500000000000012452646674022744 0ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr/smtptest/__init__.py0000664000175000017500000000165212452647411021606 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . "The lazr.smtptest package." import pkg_resources __version__ = pkg_resources.resource_string( "lazr.smtptest", "version.txt").strip() import sys if sys.version_info[0] == 3: __version__ = __version__.decode('utf-8') lazr.smtptest-2.0.3/lazr/smtptest/docs/0000775000175000017500000000000012452650023020412 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr/smtptest/docs/usage_fixture.py0000664000175000017500000000164412452647457023664 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """Doctest fixtures for running under nose.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'globs', ] from lazr.smtptest.docs.fixture import globs lazr.smtptest-2.0.3/lazr/smtptest/docs/queue.rst0000664000175000017500000001172312452646674022315 0ustar barrybarry00000000000000============ Queue server ============ As shown in the general usage_ document, you can create subclasses of the Server class to define how you want to handle received messages. A very common pattern is to use a Queue to share messages between the controlling thread and the server thread. These are nice because, unlike a mailbox based server, no sorting is required to get the messages out of the server in the same order they are sent. .. _usage: usage.html First, you need a queue. >>> try: ... from queue import Empty, Queue ... except ImportError: ... # Python 2 ... from Queue import Empty, Queue >>> queue = Queue() Then you need a server. >>> from lazr.smtptest.server import QueueServer >>> server = QueueServer('localhost', 9025, queue) Finally, you need a controller. >>> from lazr.smtptest.controller import Controller >>> controller = Controller(server) Now, start the SMTP server. >>> controller.start() Send the server a bunch of messages. >>> import smtplib >>> smtpd = smtplib.SMTP() >>> code, helo = smtpd.connect('localhost', 9025) >>> print(code, str(helo)) 220 ... Python SMTP proxy version ... >>> smtpd.sendmail('iperson@example.com', ['jperson@example.com'], """\ ... From: Irie Person ... To: Jeff Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> smtpd.sendmail('kperson@example.com', ['lperson@example.com'], """\ ... From: Kari Person ... To: Liam Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> smtpd.sendmail('mperson@example.com', ['nperson@example.com'], """\ ... From: Mary Person ... To: Neal Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} All of these messages are available in the queue. >>> while True: ... try: ... message = queue.get_nowait() ... except Empty: ... break ... print(message['message-id']) We're done with the controller. >>> controller.stop() Queue controller ================ An even more convenient interface, is to use the QueueController. >>> from lazr.smtptest.controller import QueueController >>> controller = QueueController('localhost', 9025) >>> controller.start() >>> smtpd = smtplib.SMTP() >>> code, helo = smtpd.connect('localhost', 9025) >>> print(code, str(helo)) 220 ... Python SMTP proxy version ... We now have an SMTP server that we can send some messages to. >>> smtpd.sendmail('operson@example.com', ['pperson@example.com'], """\ ... From: Onua Person ... To: Paul Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> smtpd.sendmail('qperson@example.com', ['rperson@example.com'], """\ ... From: Quay Person ... To: Raul Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> smtpd.sendmail('sperson@example.com', ['tperson@example.com'], """\ ... From: Sean Person ... To: Thom Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} And we can dump out all the messages from the controller. >>> for message in controller: ... print(message['message-id']) We can send more messages and view them too. >>> smtpd.sendmail('uperson@example.com', ['vperson@example.com'], """\ ... From: Umma Person ... To: Vern Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> for message in controller: ... print(message['message-id']) Resetting ========= Queue servers support a RSET (reset) method, which empties the queue. >>> smtpd.sendmail('wperson@example.com', ['xperson@example.com'], """\ ... From: Wynn Person ... To: Xerx Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> smtpd.sendmail('yperson@example.com', ['zperson@example.com'], """\ ... From: Yikes Person ... To: Zell Person ... Subject: A test ... Message-ID: ... ... This is a test. ... """) {} >>> controller.queue.qsize() 2 >>> controller.reset() >>> controller.queue.qsize() 0 Clean up ======== We're done with this controller. >>> controller.stop() lazr.smtptest-2.0.3/lazr/smtptest/docs/NEWS.rst0000664000175000017500000000315612452647532021740 0ustar barrybarry00000000000000====================== NEWS for lazr.smtptest ====================== 2.0.3 (2015-01-05) ================== - Always use old-style namespace package registration in ``lazr/__init__.py`` since the mere presence of this file subverts PEP 420 style namespace packages. (LP: #1407816) 2.0.2 (2014-08-20) ================== - Disable `test_suite` in setup.py; nose doesn't work well with `python setup.py test` since plugins are disabled. - Use `python setup.py nosetests` in tox.ini. 2.0.1 (2014-08-19) ================== - Remove the dependency on `distribute` which has been merged back into `setuptools`. (LP: #1273639) - Add tox.ini for the preferred way to run the test suite. 2.0 (2013-01-05) ================ - Ported to Python 3. Now support Python 2.6, 2.7, 3.2, and 3.3. - Removed the dependency on zc.buildout. - Use nose for testing. 1.3 (2011-06-07) ================ - Make the test server thread-safe with other code that starts an asyncore loop. Requires Python 2.6 or 2.7. - Be cleaner about stopping the server: before, it left sockets running ans simply cleared out the socket map. In an associated change, the EXIT smtp command sends the reply first, and then shuts down the server, rather than the other way around. 1.2 (2009-07-07) ================ - [bug 393621] QueueServer.reset() was added to clear the message queue. This is invoked by sending an SMTP RSET command to the server, or through Controller.reset(). 1.1 (2009-06-29) ================ - [bug 391650] A non-public API was added to make QueueController more easily subclassable. 1.0 (2009-06-22) ================ - Initial release lazr.smtptest-2.0.3/lazr/smtptest/docs/README_fixture.py0000664000175000017500000000164412452647433023507 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """Doctest fixtures for running under nose.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'globs', ] from lazr.smtptest.docs.fixture import globs lazr.smtptest-2.0.3/lazr/smtptest/docs/queue_fixture.py0000664000175000017500000000164412452647453023700 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """Doctest fixtures for running under nose.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'globs', ] from lazr.smtptest.docs.fixture import globs lazr.smtptest-2.0.3/lazr/smtptest/docs/__init__.py0000664000175000017500000000137212452647442022541 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """Executable documentation about lazr.smtptest.""" lazr.smtptest-2.0.3/lazr/smtptest/docs/usage.rst0000664000175000017500000001205712452646674022276 0ustar barrybarry00000000000000============================= Using the SMTP test framework ============================= The SMTP test framework provides a real SMTP server listening on a port and speaking the SMTP protocol. It runs the server in a separate thread so that the main thread can send it messages, and verify that it received the messages. To use, start by defining a subclass of the Server class. >>> from lazr.smtptest.server import Server Override the handle_message() method to do whatever you want to do with the message. For example, you might want to pass the message between the threads via a Queue. >>> try: ... from queue import Queue ... except ImportError: ... # Python 2 ... from Queue import Queue >>> queue = Queue() >>> class MyServer(Server): ... def handle_message(self, message): ... queue.put(message) Start a controller, with our new server. >>> from lazr.smtptest.controller import Controller >>> controller = Controller(MyServer('localhost', 9025)) >>> controller.start() Connect to the server... >>> from smtplib import SMTP >>> smtpd = SMTP() >>> code, helo = smtpd.connect('localhost', 9025) >>> print(code, str(helo)) 220 ... Python SMTP proxy version ... ...and send it a message. >>> smtpd.sendmail('aperson@example.com', ['bperson@example.com'], """\ ... From: Abby Person ... To: Bart Person ... Subject: A test ... Message-ID: ... ... Hi Bart, this is a test. ... """) {} Now print the message that the server has just received. >>> message = queue.get() >>> print(message.as_string()) From: Abby Person To: Bart Person Subject: A test Message-ID: X-Peer: 127.0.0.1:... X-MailFrom: aperson@example.com X-RcptTo: bperson@example.com Hi Bart, this is a test. When you're done with the server, stop it via the controller. >>> controller.stop() The server is guaranteed to be stopped. >>> # The traceback text is different between Python 2.5 and 2.6. >>> import socket >>> try: ... smtpd.connect('localhost', 9025) ... except socket.error as error: ... errno, message = error.args ... print(message) Connection refused Resetting ========= The SMTP server can be reset, which defines application specific behavior. For example, a server which stores messages in an mbox can be sent the RSET command to clear the mbox. This server stores messages in Maildir. >>> import os >>> import mailbox >>> import tempfile >>> tempdir = tempfile.mkdtemp() >>> mailbox_dir = os.path.join(tempdir, 'maildir') >>> class MyServer(Server): ... def __init__(self, host, port): ... Server.__init__(self, host, port) ... self._maildir = mailbox.Maildir(mailbox_dir) ... ... def handle_message(self, message): ... self._maildir.add(message) ... ... def reset(self): ... self._maildir.clear() >>> controller = Controller(MyServer('localhost', 9025)) >>> controller.start() Now we can send a couple of messages to the server. >>> smtpd = SMTP() >>> code, helo = smtpd.connect('localhost', 9025) >>> print(code, str(helo)) 220 ... Python SMTP proxy version ... >>> smtpd.sendmail('cperson@example.com', ['dperson@example.com'], """\ ... From: Cris Person ... To: Dave Person ... Subject: A test ... Message-ID: ... ... Hi Dave, this is a test. ... """) {} >>> smtpd.sendmail('eperson@example.com', ['fperson@example.com'], """\ ... From: Elly Person ... To: Fred Person ... Subject: A test ... Message-ID: ... ... Hi Fred, this is a test. ... """) {} >>> smtpd.sendmail('gperson@example.com', ['hperson@example.com'], """\ ... From: Gwen Person ... To: Herb Person ... Subject: A test ... Message-ID: ... ... Hi Herb, this is a test. ... """) {} All of these messages are in the mailbox. >>> for message_id in sorted(message['message-id'] ... for message in mailbox.Maildir(mailbox_dir)): ... print(message_id) Reading the messages does not affect their appearance in the mailbox. >>> for message_id in sorted(message['message-id'] ... for message in mailbox.Maildir(mailbox_dir)): ... print(message_id) But if we reset the server, the messages disappear. >>> controller.reset() >>> sum(1 for message in mailbox.Maildir(mailbox_dir)) 0 Clean up ======== >>> # In Python 2.6, this returns a 221, but not in Python 2.5. >>> status = smtpd.quit() >>> controller.stop() >>> import shutil >>> shutil.rmtree(tempdir) lazr.smtptest-2.0.3/lazr/smtptest/docs/README.rst0000664000175000017500000000253112452646674022123 0ustar barrybarry00000000000000============= LAZR smtptest ============= This is LAZR smtptest, a framework for testing SMTP-based applications and libraries. It provides a real, live SMTP server that you can send messages to, and from which you can read those test messages. This can be used to ensure proper operation of your applications which send email. Importable ========== The lazr.smtptest package is importable, and has a version number. >>> import lazr.smtptest >>> print('VERSION:', lazr.smtptest.__version__) VERSION: ... More information ================ For more general usage information, see usage_. A specific, common test regime can be found in queue_. .. _usage: docs/usage.html .. _queue: docs/queue.html Copyright ========= This file is part of lazr.smtptest. lazr.smtptest is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3 of the License. lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with lazr.smtptest. If not, see . lazr.smtptest-2.0.3/lazr/smtptest/docs/fixture.py0000664000175000017500000000234012452647446022470 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . """Doctest fixtures for running under nose.""" from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ 'globs', ] def globs(globs): """Set up globals for doctests.""" # Enable future statements to make Python 2 act more like Python 3. globs['absolute_import'] = absolute_import globs['print_function'] = print_function globs['unicode_literals'] = unicode_literals # Provide a convenient way to clean things up at the end of the test. return globs lazr.smtptest-2.0.3/lazr/__init__.py0000664000175000017500000000162112452647403017720 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest. # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . # This is a namespace package. try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) lazr.smtptest-2.0.3/setup.py0000664000175000017500000000447512452647466016374 0ustar barrybarry00000000000000# Copyright 2009-2015 Canonical Ltd. All rights reserved. # # This file is part of lazr.smtptest # # lazr.smtptest is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, version 3 of the License. # # lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public # License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with lazr.smtptest. If not, see . from setuptools import setup, find_packages __version__ = open('lazr/smtptest/version.txt').read().strip() setup( name='lazr.smtptest', version=__version__, namespace_packages=['lazr'], packages=find_packages(), include_package_data=True, zip_safe=False, maintainer='LAZR Developers', maintainer_email='lazr-developers@lists.launchpad.net', description='A test framework for SMTP based applications', long_description=""" This is LAZR smtptest, a framework for testing SMTP-based applications and libraries. It provides a real, live SMTP server that you can send messages to, and from which you can read those test messages. This can be used to ensure proper operation of your applications which send email. """, license='LGPL v3', install_requires=[ 'nose', 'setuptools', ], url='https://launchpad.net/lazr.smtptest', download_url= 'https://launchpad.net/lazr.smtptest/+download', classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Operating System :: OS Independent", 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', ], # nose plugins don't really work with `python setup.py test` so use # `python setup.py nosetests` instead, or just `tox`. Gosh, we really # should switch to nose2. :/ - BAW 2014-08-20 #test_suite='nose.collector', ) lazr.smtptest-2.0.3/COPYING.txt0000664000175000017500000001672512452646674016534 0ustar barrybarry00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. lazr.smtptest-2.0.3/setup.cfg0000664000175000017500000000041412452650023016447 0ustar barrybarry00000000000000[nosetests] verbosity = 3 with-coverage = 1 with-doctest = 1 doctest-extension = .rst doctest-options = +ELLIPSIS,+NORMALIZE_WHITESPACE,+REPORT_NDIFF doctest-fixtures = _fixture cover-package = lazr.smtptest [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 lazr.smtptest-2.0.3/PKG-INFO0000664000175000017500000000211312452650023015721 0ustar barrybarry00000000000000Metadata-Version: 1.1 Name: lazr.smtptest Version: 2.0.3 Summary: A test framework for SMTP based applications Home-page: https://launchpad.net/lazr.smtptest Author: LAZR Developers Author-email: lazr-developers@lists.launchpad.net License: LGPL v3 Download-URL: https://launchpad.net/lazr.smtptest/+download Description: This is LAZR smtptest, a framework for testing SMTP-based applications and libraries. It provides a real, live SMTP server that you can send messages to, and from which you can read those test messages. This can be used to ensure proper operation of your applications which send email. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 lazr.smtptest-2.0.3/lazr.smtptest.egg-info/0000775000175000017500000000000012452650023021153 5ustar barrybarry00000000000000lazr.smtptest-2.0.3/lazr.smtptest.egg-info/namespace_packages.txt0000664000175000017500000000000512452650023025501 0ustar barrybarry00000000000000lazr lazr.smtptest-2.0.3/lazr.smtptest.egg-info/SOURCES.txt0000664000175000017500000000142212452650023023036 0ustar barrybarry00000000000000COPYING.txt HACKING.rst MANIFEST.in README.rst conf.py setup.cfg setup.py tox.ini lazr/__init__.py lazr.smtptest.egg-info/PKG-INFO lazr.smtptest.egg-info/SOURCES.txt lazr.smtptest.egg-info/dependency_links.txt lazr.smtptest.egg-info/namespace_packages.txt lazr.smtptest.egg-info/not-zip-safe lazr.smtptest.egg-info/requires.txt lazr.smtptest.egg-info/top_level.txt lazr/smtptest/__init__.py lazr/smtptest/controller.py lazr/smtptest/server.py lazr/smtptest/version.txt lazr/smtptest/docs/NEWS.rst lazr/smtptest/docs/README.rst lazr/smtptest/docs/README_fixture.py lazr/smtptest/docs/__init__.py lazr/smtptest/docs/fixture.py lazr/smtptest/docs/queue.rst lazr/smtptest/docs/queue_fixture.py lazr/smtptest/docs/usage.rst lazr/smtptest/docs/usage_fixture.py lazr/smtptest/tests/__init__.pylazr.smtptest-2.0.3/lazr.smtptest.egg-info/dependency_links.txt0000664000175000017500000000000112452650023025221 0ustar barrybarry00000000000000 lazr.smtptest-2.0.3/lazr.smtptest.egg-info/PKG-INFO0000664000175000017500000000211312452650023022245 0ustar barrybarry00000000000000Metadata-Version: 1.1 Name: lazr.smtptest Version: 2.0.3 Summary: A test framework for SMTP based applications Home-page: https://launchpad.net/lazr.smtptest Author: LAZR Developers Author-email: lazr-developers@lists.launchpad.net License: LGPL v3 Download-URL: https://launchpad.net/lazr.smtptest/+download Description: This is LAZR smtptest, a framework for testing SMTP-based applications and libraries. It provides a real, live SMTP server that you can send messages to, and from which you can read those test messages. This can be used to ensure proper operation of your applications which send email. Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 lazr.smtptest-2.0.3/lazr.smtptest.egg-info/top_level.txt0000664000175000017500000000000512452650023023700 0ustar barrybarry00000000000000lazr lazr.smtptest-2.0.3/lazr.smtptest.egg-info/requires.txt0000664000175000017500000000002012452650023023543 0ustar barrybarry00000000000000nose setuptools lazr.smtptest-2.0.3/lazr.smtptest.egg-info/not-zip-safe0000664000175000017500000000000112452650023023401 0ustar barrybarry00000000000000 lazr.smtptest-2.0.3/tox.ini0000664000175000017500000000012412452647217016152 0ustar barrybarry00000000000000[tox] envlist = py27,py32,py33,py34 [testenv] commands = python setup.py nosetests lazr.smtptest-2.0.3/HACKING.rst0000664000175000017500000000267712452646674016462 0ustar barrybarry00000000000000.. This file is part of lazr.smtptest. lazr.smtptest is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3 of the License. lazr.smtptest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with lazr.smtptest. If not, see . ======================== Hacking on lazr.smtptest ======================== These are guidelines for hacking on the lazr.smtptest project. But first, please see the common hacking guidelines at: http://dev.launchpad.net/Hacking Getting help ============ If you find bugs in this package, you can report them here: https://launchpad.net/lazr.smtptest If you want to discuss this package, join the team and mailing list here: https://launchpad.net/~lazr-users or send a message to: lazr-users@lists.launchpad.net Running the tests ================= The tests suite requires tox_ and nose_ and is compatible with both Python 2 and Python 3. To run the full test suite:: $ tox .. _nose: https://nose.readthedocs.org/en/latest/ .. _tox: https://testrun.org/tox/latest/ lazr.smtptest-2.0.3/conf.py0000664000175000017500000002044112452647365016146 0ustar barrybarry00000000000000# -*- coding: utf-8 -*- # # lazr.smtptest documentation build configuration file, created by # sphinx-quickstart on Mon Jan 7 10:37:37 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. from __future__ import print_function import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'README' # General information about the project. project = u'lazr.smtptest' copyright = u'2013-2015, LAZR developers' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = open('lazr/smtptest/version.txt').read().strip() # The full version, including alpha/beta/rc tags. release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build', 'eggs'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'lazrsmtptestdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'lazrsmtptest.tex', u'lazr.smtptest Documentation', u'LAZR developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'lazrsmtptest', u'lazr.smtptest Documentation', [u'LAZR developers'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'lazrsmtptest', u'lazr.smtptest Documentation', u'LAZR developers', 'lazrsmtptest', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # Make upload to packages.python.org happy. def index_html(): import errno cwd = os.getcwd() try: try: os.makedirs('build/sphinx/html') except OSError as error: if error.errno != errno.EEXIST: raise os.chdir('build/sphinx/html') try: os.symlink('README.html', 'index.html') print('index.html -> README.html') except OSError as error: if error.errno != errno.EEXIST: raise finally: os.chdir(cwd) import atexit atexit.register(index_html) lazr.smtptest-2.0.3/README.rst0000664000175000017500000000051612452646674016341 0ustar barrybarry00000000000000======================== Welcome to lazr.smtptest ======================== Contents: .. toctree:: :maxdepth: 2 lazr/smtptest/docs/README lazr/smtptest/docs/usage lazr/smtptest/docs/queue lazr/smtptest/docs/NEWS HACKING Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search`