当前位置: 首页>>代码示例>>Python>>正文


Python Controller.start方法代码示例

本文整理汇总了Python中aiosmtpd.controller.Controller.start方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.start方法的具体用法?Python Controller.start怎么用?Python Controller.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiosmtpd.controller.Controller的用法示例。


在下文中一共展示了Controller.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def setUp(self):
     self.stream = StringIO()
     handler = Debugging(self.stream)
     controller = Controller(handler)
     controller.start()
     self.addCleanup(controller.stop)
     self.address = (controller.hostname, controller.port)
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:9,代码来源:test_handlers.py

示例2: test_real_mail_aiosmtpd

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
    def test_real_mail_aiosmtpd(self):
        """ Test sending messages with a real-world SMTPD server """
        if aiosmtpd is None:
            self.skipTest('aiosmtpd not available')

        # Start an smtp server
        mail_handler = StashingHandler()
        controller = Controller(mail_handler, loop=None,
                                hostname='localhost', port=self.smtpd_port)
        controller.start()

        # Give it time to settle
        sleep(0.5)

        # Initialize a Postman
        postman = Postman('[email protected]',
                          NoLoginSMTP('localhost', self.smtpd_port, None, None))

        # Send messages
        with postman.connect() as c:
            # Send plaintext message
            msg = Message(['[email protected]'], 'Subject', 'HTML message')
            c.sendmail(msg)

            # Send unicode message
            msg = Message(['[email protected]'], u'Håkon', u'Håkon')
            c.sendmail(msg)

        # Done
        controller.stop()

        # Test
        self.assertEqual(len(mail_handler.mail), 2)
开发者ID:kolypto,项目名称:py-mailem,代码行数:35,代码来源:smtp-test.py

示例3: test_mail_with_compatible_smtputf8

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_mail_with_compatible_smtputf8(self):
     handler = ReceivingHandler()
     controller = Controller(handler)
     controller.start()
     self.addCleanup(controller.stop)
     recipient = 'bart\[email protected]'
     sender = 'anne\[email protected]'
     with SMTP(controller.hostname, controller.port) as client:
         client.ehlo('example.com')
         client.send(bytes(
             'MAIL FROM: <' + sender + '> SMTPUTF8\r\n',
             encoding='utf-8'))
         code, response = client.getreply()
         self.assertEqual(code, 250)
         self.assertEqual(response, b'OK')
         client.send(bytes(
             'RCPT TO: <' + recipient + '>\r\n',
             encoding='utf-8'))
         code, response = client.getreply()
         self.assertEqual(code, 250)
         self.assertEqual(response, b'OK')
         code, response = client.data('')
         self.assertEqual(code, 250)
         self.assertEqual(response, b'OK')
     self.assertEqual(handler.box[0].rcpt_tos[0], recipient)
     self.assertEqual(handler.box[0].mail_from, sender)
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:28,代码来源:test_smtp.py

示例4: test_helo_hook

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_helo_hook(self):
     controller = Controller(HELOHandler())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         code, response = client.helo('me')
     self.assertEqual(code, 250)
     self.assertEqual(response, b'geddy.example.com')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:10,代码来源:test_handlers.py

示例5: test_socket_error

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_socket_error(self):
     # Testing starting a server with a port already in use
     s1 = Controller(Sink(), port=8025)
     s2 = Controller(Sink(), port=8025)
     self.addCleanup(s1.stop)
     self.addCleanup(s2.stop)
     s1.start()
     self.assertRaises(socket.error, s2.start)
开发者ID:aio-libs,项目名称:aiosmtpd,代码行数:10,代码来源:test_server.py

示例6: test_smtp_utf8

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_smtp_utf8(self):
     controller = Controller(Sink())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         code, response = client.ehlo('example.com')
     self.assertEqual(code, 250)
     self.assertIn(b'SMTPUTF8', response.splitlines())
开发者ID:aio-libs,项目名称:aiosmtpd,代码行数:10,代码来源:test_server.py

示例7: test_server_attribute

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_server_attribute(self):
     controller = Controller(Sink())
     self.assertIsNone(controller.server)
     try:
         controller.start()
         self.assertIsNotNone(controller.server)
     finally:
         controller.stop()
         self.assertIsNone(controller.server)
开发者ID:aio-libs,项目名称:aiosmtpd,代码行数:11,代码来源:test_server.py

示例8: test_ehlo_hook

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_ehlo_hook(self):
     controller = Controller(EHLOHandler())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         code, response = client.ehlo('me')
     self.assertEqual(code, 250)
     lines = response.decode('utf-8').splitlines()
     self.assertEqual(lines[-1], 'alex.example.com')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:11,代码来源:test_handlers.py

示例9: test_default_greeting

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_default_greeting(self):
     controller = Controller(Sink())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP() as client:
         code, msg = client.connect(controller.hostname, controller.port)
         self.assertEqual(code, 220)
         # The hostname prefix is unpredictable.
         self.assertEqual(msg[-len(GREETING):], bytes(GREETING, 'utf-8'))
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:11,代码来源:test_smtp.py

示例10: test_mail_with_unrequited_smtputf8

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_mail_with_unrequited_smtputf8(self):
     controller = Controller(Sink())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         client.ehlo('example.com')
         code, response = client.docmd('MAIL FROM: <[email protected]>')
         self.assertEqual(code, 250)
         self.assertEqual(response, b'OK')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:11,代码来源:test_smtp.py

示例11: test_mail_hook

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_mail_hook(self):
     controller = Controller(MAILHandler())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         client.helo('me')
         code, response = client.mail('[email protected]')
     self.assertEqual(code, 250)
     self.assertEqual(response, b'Yeah, sure')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:11,代码来源:test_handlers.py

示例12: test_mail_with_incompatible_smtputf8

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_mail_with_incompatible_smtputf8(self):
     controller = Controller(Sink())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         client.ehlo('example.com')
         code, response = client.docmd(
             'MAIL FROM: <[email protected]> SMTPUTF8=YES')
         self.assertEqual(code, 501)
         self.assertEqual(response, b'Error: SMTPUTF8 takes no arguments')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:12,代码来源:test_smtp.py

示例13: test_mail_invalid_body

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_mail_invalid_body(self):
     controller = Controller(Sink())
     controller.start()
     self.addCleanup(controller.stop)
     with SMTP(controller.hostname, controller.port) as client:
         client.ehlo('example.com')
         code, response = client.docmd(
             'MAIL FROM: <[email protected]> BODY 9BIT')
         self.assertEqual(code, 501)
         self.assertEqual(response,
                          b'Error: BODY can only be one of 7BIT, 8BITMIME')
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:13,代码来源:test_smtp.py

示例14: test_deliver_bytes

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
 def test_deliver_bytes(self):
     with ExitStack() as resources:
         controller = Controller(self.proxy, port=9024)
         controller.start()
         resources.callback(controller.stop)
         client = resources.enter_context(
             SMTP(*(controller.hostname, controller.port)))
         client.sendmail(
             '[email protected]', ['[email protected]'], self.source)
         client.quit()
     self.assertEqual(self.upstream.content, self.expected)
     self.assertEqual(self.upstream.original_content, self.expected)
开发者ID:kozzztik,项目名称:aiosmtpd,代码行数:14,代码来源:test_handlers.py

示例15: __init__

# 需要导入模块: from aiosmtpd.controller import Controller [as 别名]
# 或者: from aiosmtpd.controller.Controller import start [as 别名]
class CapturingAiosmtpdServer:
    """An async SMTP server / context manager for testing RPC effects."""

    def __init__(self):
        self.messages = []
        self.handler = CapturingAiosmtpdHandler(context=self)
        self.controller = Controller(
            handler=self.handler, hostname="localhost", port=10025)

    def __enter__(self):
        self.controller.start()
        return self

    def __exit__(self, *exc):
        self.controller.stop()
开发者ID:lindsay-stevens,项目名称:limesurveyrc2api,代码行数:17,代码来源:utils.py


注:本文中的aiosmtpd.controller.Controller.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。