ϪfdZddlmZmZddlmZddlmZmZddl m Z ddl m Z Gdde Z Gd d ZGd d e Zy )z Tests for L{twisted.mail.tap}. )defer endpoints) protocols)Options makeService) UsageError)TestCasecReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zy ) OptionsTestszK Tests for the command line option parser used for I{twistd mail}. c|j|_t|jd5}|jddddy#1swYyxYw)Nwzsomeuser: differentuser )mktemp aliasFilenameopenwrite)self aliasFiles @/usr/lib/python3/dist-packages/twisted/mail/test/test_options.pysetUpzOptionsTests.setUpsD![[] $$$c * :i OO8 9 : : :s AAcn|jttjd|jgy)zi Test that adding an aliases(5) file before adding a domain raises a UsageError. --aliasesN) assertRaisesrr parseOptionsrrs rtestAliasesWithoutDomainz%OptionsTests.testAliasesWithoutDomains,   ..d>P>P0Q cRtjddd|jgy)z Test that adding an aliases(5) file to an IAliasableDomain at least doesn't raise an unhandled exception. z--maildirdbmdomainzexample.com=example.comrN)rrrrs r testAliaseszOptionsTests.testAliases"s+  $)""   rct}|jd|zdg|jt||d|j ||dt j y)z Use L{Options} to parse a single service configuration parameter and verify that an endpoint of the correct type is added to the list for that service. z--ztcp:1234rNrr assertEquallenassertIsInstancerTCP4ServerEndpoint)rserviceoptionss r _endpointTestzOptionsTests._endpointTest0s\ )dWnj9: WW-.2 gg.q193O3OPrc&|jdy)z When I{--smtp} is given a TCP endpoint description as an argument, a TCPServerEndpoint is added to the list of SMTP endpoints. smtpNr(rs rtest_endpointSMTPzOptionsTests.test_endpointSMTP; 6"rc&|jdy)z When I{--pop3} is given a TCP endpoint description as an argument, a TCPServerEndpoint is added to the list of POP3 endpoints. pop3Nr+rs rtest_endpointPOP3zOptionsTests.test_endpointPOP3Br-rcJt}|jg|jt|dd|j |ddt j |jt|dd|j |ddt j y)zO POP3 and SMTP each listen on a TCP4ServerEndpoint by default. r/r rr*Nr!rr's rtest_protoDefaultszOptionsTests.test_protoDefaultsIs)R  WV_-q1 gfoa0)2N2NO WV_-q1 gfoa0)2N2NOrct}|jdg|j|jddg|j |jddgt}|jdg|j |jddg|j|jddgy)zg The I{--no-pop3} and I{--no-smtp} options disable POP3 and SMTP respectively. --no-pop3Nr/r* --no-smtp)rrr" _getEndpointsassertNotEqualr2s rtest_protoDisablezOptionsTests.test_protoDisableVs )k]+ ..tV)>?rcD|jdtjy)z If one or more endpoints is included in the configuration passed to L{makeService} for the C{"smtp"} key, a service for starting an SMTP server is constructed for each of them and attached to the returned service. r*N)rbr SMTPFactoryrs r test_smtpzMakeServiceTests.test_smtprfrN)rJrKrLrMrbrerirNrrrWrWsB"@@rrWN)rMtwisted.internetrr twisted.mailrtwisted.mail.taprrtwisted.python.usagertwisted.trial.unittestr r rPrWrNrrrosD."1++sB8sBl # #&@x&@r