%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f	-��8�dZddlmZddlmZddlmZdZdZdZ	dZ
Gd	�d
ej�ZGd�dej�Z
Gd
�dej�ZGd�dej�ZGd�dej�ZGd�dej�Zy)z4
Tests for L{twisted.words.protocols.jabber.error}.
�)�unittest)�error)�domishz$http://www.w3.org/XML/1998/namespace� http://etherx.jabber.org/streamsz#urn:ietf:params:xml:ns:xmpp-streamsz#urn:ietf:params:xml:ns:xmpp-stanzasc�,�eZdZdd�Zdd�Zdd�Zdd�Zy)�BaseErrorTestsNc���tjd�}|j�}|j|jd�|jt
|j�d�y)z<
        Test getting an element for a plain error.
        �feature-not-implementedN�)r�	BaseError�
getElement�assertIdentical�uri�assertEqual�len�children��self�e�elements   �E/usr/lib/python3/dist-packages/twisted/words/test/test_jabbererror.py�test_getElementPlainz#BaseErrorTests.test_getElementPlainsM��
�O�O�5�6���,�,�.�����W�[�[�$�/�����W�-�-�.��2�c�F�tjdd�}|j�}|jt	|j
�d�|jt
|j�d�|j|jjtdf�d�y)zC
        Test getting an element for an error with a text.
        r
�text��langN)
rrr
rrr�strr�getAttribute�NS_XMLrs   r�test_getElementTextz"BaseErrorTests.test_getElementTextsx��
�O�O�5�v�>���,�,�.������W�-�-�.��2�����W�\�\�*�F�3�������2�2�F�F�3C�D�d�Krc�0�tjddd�}|j�}|jt	|j
�d�|jt
|j�d�|j|jtdfd�y)zP
        Test getting an element for an error with a text and language.
        r
r�en_USrrN)	rrr
rrrrrr rs   r�test_getElementTextLangz&BaseErrorTests.test_getElementTextLang'st��
�O�O�5�v�w�G���,�,�.������W�-�-�.��2�����W�\�\�*�F�3�������v�v�&6�7��Arc��tjd�}tjd|��}|j	�}|jt
|j�d�|j|j|�y)zV
        Test getting an element for an error with an app specific condition.
        )�testns�myerrorr
)�appConditionrN)	r�Elementrrr
rrrr')r�acrrs    r�test_getElementAppConditionz*BaseErrorTests.test_getElementAppCondition1s^���^�^�1�
2���O�O�5�B�G���,�,�.������W�-�-�.��2�������"�-r��returnN)�__name__�
__module__�__qualname__rr!r$r+�rrrrs��3�L�B�.rrc�$�eZdZdd�Zdd�Zdd�Zy)�StreamErrorTestsNc��tjd�}|j�}|j|jt
�y)zK
        Test namespace of the element representation of an error.
        r
N)r�StreamErrorr
rr�
NS_STREAMSrs   rrz%StreamErrorTests.test_getElementPlain=s4��
���7�8���,�,�.��������j�1rc��tjd�}|j�}|jtt|d�j�y�zR
        Test that the error condition element has the correct namespace.
        r
N)rr5r
r�NS_XMPP_STREAMS�getattrrrs   r�!test_getElementConditionNamespacez2StreamErrorTests.test_getElementConditionNamespaceE�A��
���7�8���,�,�.������W�W�.G�H�L�L�	
rc��tjdd�}|j�}|jt|j
j�y)�M
        Test that the error text element has the correct namespace.
        r
rN)rr5r
rr9rrrs   r�test_getElementTextNamespacez-StreamErrorTests.test_getElementTextNamespaceOs<��
���7��@���,�,�.������'�,�,�*:�*:�;rr,)r.r/r0rr;r?r1rrr3r3<s��2�
�<rr3c�@�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zd	d�Zd	d�Z	y)
�StanzaErrorTestsz)
    Tests for L{error.StreamError}.
    Nc��tjd�}|jd|j�|jd|j�y)zI
        Remote Server Timeout should yield type wait, code 504.
        zremote-server-timeout�wait�504N)r�StanzaErrorr�type�code)rrs  r�test_typeRemoteServerTimeoutz-StanzaErrorTests.test_typeRemoteServerTimeout]s=��
���5�6���������(��������'rc���tjd�}|j�}|j|jd�|j|dd�|j|dd�y)zC
        Test getting an element for a plain stanza error.
        r
NrF�cancelrG�501�rrEr
rrrs   rrz%StanzaErrorTests.test_getElementPlaines\��
���7�8���,�,�.��������d�+�������(�3�������%�0rc���tjdd�}|j�}|j|jd�|j|dd�|j|dd�y)zO
        Test getting an element for a stanza error with a given type.
        r
�authNrFrGrKrLrs   r�test_getElementTypez$StanzaErrorTests.test_getElementTypeos^��
���7��@���,�,�.��������d�+�������&�1�������%�0rc��tjd�}|j�}|jtt|d�j�yr8)rrEr
r�NS_XMPP_STANZASr:rrs   rr;z2StanzaErrorTests.test_getElementConditionNamespaceyr<rc��tjdd��}|j�}|jt|j
j�y)r>r
r)rN)rrEr
rrQrrrs   rr?z-StanzaErrorTests.test_getElementTextNamespace�s<��
���7�f�E���,�,�.������'�,�,�*:�*:�;rc�*�tjd�}d|d<d|d<d|d<tjd�}|j	|�}|j||�|j
|dd�|j
|dd�|j
|dd	�|j
|jjd
jd�|j
|jdd�|j|j|j�y)
z�
        Test an error response is generated from a stanza.

        The addressing on the (new) response stanza should be reversed, an
        error child (with proper properties) added and the type set to
        C{'error'}.
        )z
jabber:client�message�chatrFzuser1@example.com�tozuser2@example.com/resource�from�service-unavailablerrrJN)
rr)rrE�
toResponse�assertNotIdenticalrr�name�assertNotEqual)r�stanzar�responses    r�test_toResponsez StanzaErrorTests.test_toResponse�s������ <�=����v��*��t��5��v�����3�4���<�<��'������&�1�����&�)�+>�?�����$��)E�F�����&�)�7�3�������0�0��3�8�8�:O�P��������/��:����F�O�O�X�->�->�?rr,)
r.r/r0�__doc__rHrrOr;r?r_r1rrrArAXs&���(�1�1�
�<�@rrAc�H�eZdZdZd
d�Zd
d�Zd
d�Zd
d�Zd
d�Zd
d�Z	d
d	�Z
y)�ParseErrorTestsz)
    Tests for L{error._parseError}.
    Nc�8�tjd�|_y)N)Nr)rr)r)rs r�setUpzParseErrorTests.setUp�s���^�^�O�4��
rc�r�tj|jd�}|jddddd�|�y)z:
        Test parsing of the empty error element.
        �errornsN)�	conditionr�textLangr()r�_parseErrorr�r�results  r�
test_emptyzParseErrorTests.test_empty�s8���"�"�4�:�:�y�9�������$�PT�U��	
rc��|jjd�tj|jd�}|jd|d�y)zD
        Test parsing of an error element with a condition.
        )rf�bad-requestrfrnrgN�r�
addElementrirrjs  r�test_conditionzParseErrorTests.test_condition�sB��	
�
�
���8�9��"�"�4�:�:�y�9�������{�(;�<rc���|jjd�}|jd�tj|jd�}|j	d|d�|j	d|d�y)z?
        Test parsing of an error element with a text.
        �rfr�testrfrNrh)rrp�
addContentrir�rrrks   r�	test_textzParseErrorTests.test_text�sd���z�z�$�$�%8�9��������"�"�4�:�:�y�9���������0�����v�j�1�2rc���|jjd�}d|tdf<|jd�tj|jd�}|jd|d�y)zW
        Test parsing of an error element with a text with a defined language.
        rsr#rrtrfrhN)rrpr rurirrvs   r�
test_textLangzParseErrorTests.test_textLang�s^���z�z�$�$�%8�9��&��V�V�^��������"�"�4�:�:�y�9������&��"4�5rc��|jjd�}tj|jd�}|j||d�y)zR
        Test parsing of an error element with an app specific condition.
        �r&rgrfr(Nro�rrgrks   r�test_appConditionz!ParseErrorTests.test_appCondition�sD���J�J�)�)�*A�B�	��"�"�4�:�:�y�9������F�>�$:�;rc���|jjd�|jjd�}tj|jd�}|j||d�y)zY
        Test parsing of an error element with multiple app specific conditions.
        r{)r&�
condition2rfr(Nror|s   r�test_appConditionMultiplez)ParseErrorTests.test_appConditionMultiple�sW��	
�
�
���5�6��J�J�)�)�*B�C�	��"�"�4�:�:�y�9������F�>�$:�;rr,)r.r/r0r`rdrlrqrwryr}r�r1rrrbrb�s*���5�
�=�3�6�<�<rrbc��eZdZdd�Zdd�Zy)�ExceptionFromStanzaTestsNc�D�tjd�}|jd�}|jd�|jd�}d|d<|jtdf�|jd�}d	|d
<t	j
|�}|j
|tj�|jd|j�|jd|j�|j||j�|j|g|j�y)a�
        Test basic operations of exceptionFromStanza.

        Given a realistic stanza, check if a sane exception is returned.

        Using this stanza::

          <iq type='error'
              from='pubsub.shakespeare.lit'
              to='francisco@denmark.lit/barracks'
              id='subscriptions1'>
            <pubsub xmlns='http://jabber.org/protocol/pubsub'>
              <subscriptions/>
            </pubsub>
            <error type='cancel'>
              <feature-not-implemented
                xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
              <unsupported xmlns='http://jabber.org/protocol/pubsub#errors'
                           feature='retrieve-subscriptions'/>
            </error>
          </iq>
        �Nr])z!http://jabber.org/protocol/pubsub�pubsub�
subscriptionsrrJrFr
)z(http://jabber.org/protocol/pubsub#errors�unsupportedzretrieve-subscriptions�featureN)
rr)rprQr�exceptionFromStanza�assertIsInstancerErrgrFr(r)rr]�pr�ucrks      r�
test_basicz#ExceptionFromStanzaTests.test_basic�s���0��� 0�1�����M�N��	���_�%����g�&����&�	�	���o�'@�A�B�
�\�\�U�
V��0��9�
��*�*�6�2�����f�e�&7�&7�8����2�F�4D�4D�E�����6�;�;�/�����V�0�0�1����!��f�o�o�.rc���tjd�}|jdd��}|jdd��}d|d<tj|�}|j|tj�|jd	|j�|jd
|j�|jd|j�|j|g|j�y)a�
        Test legacy operations of exceptionFromStanza.

        Given a realistic stanza with only legacy (pre-XMPP) error information,
        check if a sane exception is returned.

        Using this stanza::

          <message type='error'
                   to='piers@pipetree.com/Home'
                   from='qmacro@jaber.org'>
            <body>Are you there?</body>
            <error code='502'>Unable to resolve hostname.</error>
          </message>
        r��bodyzAre you there?)�contentrzUnable to resolve hostname.�502rGrXrCN)rr)rprr�r�rErrgrFrr)rr]r�rrks     r�test_legacyz$ExceptionFromStanzaTests.test_legacys��� ��� 0�1�����f�.>��?�����g�/L��M����&�	��*�*�6�2�����f�e�&7�&7�8����.��0@�0@�A��������-����6����D����!��f�o�o�.rr,)r.r/r0r�r�r1rrr�r��s
��&/�P/rr�c��eZdZdd�Zy)�ExceptionFromStreamErrorTestsNc��tjd�}|jtdf�t	j
|�}|j
|tj�|jd|j�y)ac
        Test basic operations of exceptionFromStreamError.

        Given a realistic stream error, check if a sane exception is returned.

        Using this error::

          <stream:error xmlns:stream='http://etherx.jabber.org/streams'>
            <xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
          </stream:error>
        )rrzxml-not-well-formedN)
rr)rpr9r�exceptionFromStreamErrorr�r5rrg)rrrks   rr�z(ExceptionFromStreamErrorTests.test_basic)sb��
�N�N�H�I��	���o�'<�=�>��/�/��2�����f�e�&7�&7�8����.��0@�0@�Arr,)r.r/r0r�r1rrr�r�(s��Brr�N)r`�
twisted.trialr�twisted.words.protocols.jabberr�twisted.words.xishrr r6r9rQ�TestCaserr3rArbr�r�r1rr�<module>r�s����
#�0�%�	/��
/�
�7��7��&.�X�&�&�&.�R<�x�(�(�<�8G@�x�(�(�G@�T=<�h�'�'�=<�@C/�x�0�0�C/�LB�H�$5�$5�Br

Zerion Mini Shell 1.0