コード例 #1
0
 def __init__(self, host, port):
     self._tmp_dir = TemporaryDirectory()
     super().__init__(handler=Mailbox(
         os.path.join(self._tmp_dir.name, 'mailbox')),
                      hostname=host,
                      port=port,
                      ready_timeout=2.0)
コード例 #2
0
 def setUp(self):
     self.tempdir = TemporaryDirectory()
     self.addCleanup(self.tempdir.cleanup)
     self.maildir_path = os.path.join(self.tempdir.name, 'maildir')
     self.handler = handler = Mailbox(self.maildir_path)
     controller = Controller(handler)
     controller.start()
     self.addCleanup(controller.stop)
     self.address = (controller.hostname, controller.port)
コード例 #3
0
ファイル: test_handlers.py プロジェクト: wevsty/aiosmtpd
def mailbox_controller(temp_maildir,
                       get_controller) -> Generator[Controller, None, None]:
    handler = Mailbox(temp_maildir)
    controller = get_controller(handler)
    controller.start()
    Global.set_addr_from(controller)
    #
    yield controller
    #
    controller.stop()
コード例 #4
0
def generate_email_server(tmpdir):
    """
    This starts an SMTP server in a new thread, which listens on port 9487.

    STARTTLS is enabled using a self-signed certificate.

    """

    if not isinstance(tmpdir, py.path.local):
        tmpdir = py.path.local(tmpdir)

    cert_file, key_file = generate_cert_and_key(tmpdir)
    ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    ctx.load_cert_chain(cert_file, keyfile=key_file)

    maildir = str(tmpdir.join("maildir"))

    controller = STARTTLSController(
        Mailbox(maildir), hostname="localhost", port=9487, ssl_context=ctx
    )
    return controller, maildir
コード例 #5
0
 def test_mailbox_cli(self):
     with TemporaryDirectory() as tmpdir:
         handler = Mailbox.from_cli(self.parser, tmpdir)
         self.assertIsInstance(handler.mailbox, Maildir)
         self.assertEqual(handler.mail_dir, tmpdir)
コード例 #6
0
ファイル: test_handlers.py プロジェクト: kozzztik/aiosmtpd
 def test_mailbox_cli(self):
     with TemporaryDirectory() as tmpdir:
         handler = Mailbox.from_cli(self.parser, tmpdir)
         self.assertIsInstance(handler.mailbox, Maildir)
         self.assertEqual(handler.mail_dir, tmpdir)