%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/mail/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/mail/test/__pycache__/test_options.cpython-312.pyc

�

Ϫ�f���dZddlmZmZddlmZddlmZmZddl	m
Z
ddlmZGd�de�Z
Gd	�d
�ZGd�de�Zy
)z 
Tests for L{twisted.mail.tap}.
�)�defer�	endpoints)�	protocols)�Options�makeService)�
UsageError)�TestCasec�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�OptionsTestszK
    Tests for the command line option parser used for I{twistd mail}.
    c��|j�|_t|jd�5}|jd�ddd�y#1swYyxYw)N�wzsomeuser:	differentuser
)�mktemp�
aliasFilename�open�write)�self�	aliasFiles  �@/usr/lib/python3/dist-packages/twisted/mail/test/test_options.py�setUpzOptionsTests.setUpsD��!�[�[�]���
�$�$�$�c�
*�	:�i��O�O�8�9�	:�	:�	:�s�A�Ac�n�|jtt�jd|jg�y)zi
        Test that adding an aliases(5) file before adding a domain raises a
        UsageError.
        �	--aliasesN)�assertRaisesrr�parseOptionsr�rs r�testAliasesWithoutDomainz%OptionsTests.testAliasesWithoutDomains,��
	
�����	�.�.��d�>P�>P�0Q�	
�c�R�t�jddd|jg�y)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+��
	�	���$�)���"�"�	
�	
rc���t�}|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:1234�rN�rr�assertEqual�len�assertIsInstancer�TCP4ServerEndpoint)r�service�optionss   r�
_endpointTestzOptionsTests._endpointTest0s\���)�����d�W�n�j�9�:�����W�W�-�.��2����g�g�.�q�1�9�3O�3O�Prc�&�|jd�y)z�
        When I{--smtp} is given a TCP endpoint description as an argument, a
        TCPServerEndpoint is added to the list of SMTP endpoints.
        �smtpN�r(rs r�test_endpointSMTPzOptionsTests.test_endpointSMTP;���
	
���6�"rc�&�|jd�y)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 r�test_endpointPOP3zOptionsTests.test_endpointPOP3Br-rc�J�t�}|jg�|jt|d�d�|j	|ddt
j�|jt|d�d�|j	|ddt
j�y)zO
        POP3 and SMTP each listen on a TCP4ServerEndpoint by default.
        r/r rr*Nr!�rr's  r�test_protoDefaultszOptionsTests.test_protoDefaultsIs����)�����R� �����W�V�_�-�q�1����g�f�o�a�0�)�2N�2N�O�����W�V�_�-�q�1����g�f�o�a�0�)�2N�2N�Orc��t�}|jdg�|j|jdd�g�|j	|jdd�g�t�}|jdg�|j	|jdd�g�|j|jdd�g�y)zg
        The I{--no-pop3} and I{--no-smtp} options disable POP3 and SMTP
        respectively.
        �	--no-pop3Nr/r*�	--no-smtp)rrr"�
_getEndpoints�assertNotEqualr2s  r�test_protoDisablezOptionsTests.test_protoDisableVs���
�)�����k�]�+�����.�.�t�V�<�b�A����G�1�1�$��?��D��)�����k�]�+����G�1�1�$��?��D�����.�.�t�V�<�b�Arc�^�t�}|jt|jddg�y)zI
        If all protocols are disabled, L{UsageError} is raised.
        r5r6N)rrrrr2s  r�test_allProtosDisabledErrorz(OptionsTests.test_allProtosDisabledErrores+���)�������,�,��[�/I�	
rc��t�}|jt|jdg�}|j	dt|��y)zu
        If I{--esmtp} is given without I{--hostname}, L{Options.parseOptions}
        raises L{UsageError}.
        z--esmtpz--esmtp requires --hostnameN)rrrrr"�str)rr'�excs   r�test_esmtpWithoutHostnamez&OptionsTests.test_esmtpWithoutHostnamens<��
�)�����
�G�,@�,@�9�+�N�����6��C��Arc��t�}|jddg�|jt|d�d�|dd}|j}|j
jj}|D]}|j|||��y)zC
        Tests that the --auth option registers a checker.
        z--authzmemory:admin:admin:bob:password�credCheckersr rN)rrr"r#�credentialInterfacesr&�
smtpPortal�checkers)rr'�checker�
interfaces�registered_checkers�ifaces      r�	test_authzOptionsTests.test_authws����)�����h�(I�J�K�����W�^�4�5�q�9��.�)�!�,���1�1�
�%�o�o�8�8�A�A���	B�E����W�&9�%�&@�A�	BrN)�__name__�
__module__�__qualname__�__doc__rrrr(r,r0r3r9r;r?rI�rrrrsC���:�

�
�	Q�#�#�P�
B�
�B�Brrc��eZdZdZdZd�Zy)�SpyEndpointzG
    SpyEndpoint remembers what factory it is told to listen with.
    Nc�:�||_tjd�S)N)�
listeningWithr�succeed)r�factorys  r�listenzSpyEndpoint.listen�s��$����}�}�T�"�"r)rJrKrLrMrRrUrNrrrPrP�s����M�#rrPc�"�eZdZdZd�Zd�Zd�Zy)�MakeServiceTestsz3
    Tests for L{twisted.mail.tap.makeService}
    c�J�t�}t�}t�}||g||<t|�}|j�|j	�|j|j�|j|j|�|j|j|�y)z�
        Configure a service with two endpoints for the protocol associated with
        C{key} and verify that when the service is started a factory of type
        C{factoryClass} is used to listen on each of them.
        N)	rPrr�privilegedStartService�startService�
addCleanup�stopServicer$rR)r�key�factoryClass�	cleartext�secure�configr&s       r�_endpointServerTestz$MakeServiceTests._endpointServerTest�s��� �M�	������� �&�)��s���f�%���&�&�(���������+�+�,����i�5�5�|�D����f�2�2�L�Arc�D�|jdtj�y)z�
        If one or more endpoints is included in the configuration passed to
        L{makeService} for the C{"pop3"} key, a service for starting a POP3
        server is constructed for each of them and attached to the returned
        service.
        r/N)rbr�POP3Factoryrs r�	test_pop3zMakeServiceTests.test_pop3����	
� � ���)>�)>�?rc�D�|jdtj�y)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_smtp�rfrN)rJrKrLrMrbrerirNrrrWrW�s���B�"@�@rrWN)rM�twisted.internetrr�twisted.mailr�twisted.mail.taprr�twisted.python.usager�twisted.trial.unittestr	rrPrWrNrr�<module>rosD���.�"�1�+�+�sB�8�sB�l	#�	#�&@�x�&@r

Zerion Mini Shell 1.0