HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/words/test/__pycache__/test_jabbererror.cpython-38.pyc
U


W[-�@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZdZdZ
d	Zd
ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZdS)z4
Tests for L{twisted.words.protocols.jabber.error}.
�)�absolute_import�division)�unicode)�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@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�BaseErrorTestscCs6t�d�}|��}|�|jd�|�t|j�d�dS)z<
        Test getting an element for a plain error.
        �feature-not-implementedN�)r�	BaseError�
getElementZassertIdentical�uri�assertEqual�len�children��self�e�element�r�E/usr/lib/python3/dist-packages/twisted/words/test/test_jabbererror.py�test_getElementPlains
z#BaseErrorTests.test_getElementPlaincCsTt�dd�}|��}|�t|j�d�|�t|j�d�|�|j�t	df�d�dS)zC
        Test getting an element for an error with a text.
        r
�text��langN)
rrr
rrrrrZgetAttribute�NS_XMLrrrr�test_getElementText s
z"BaseErrorTests.test_getElementTextcCsTt�ddd�}|��}|�t|j�d�|�t|j�d�|�|jtdfd�dS)zP
        Test getting an element for an error with a text and language.
        r
r�en_USrrN)	rrr
rrrrrrrrrr�test_getElementTextLang*s
z&BaseErrorTests.test_getElementTextLangcCsDt�d�}tjd|d�}|��}|�t|j�d�|�|j|�dS)zV
        Test getting an element for an error with an app specific condition.
        )�testns�myerrorr
)�appConditionrN)	r�Elementrrr
rrrr!)rZacrrrrr�test_getElementAppCondition4s

z*BaseErrorTests.test_getElementAppConditionN)�__name__�
__module__�__qualname__rrrr$rrrrr	s	

r	c@s$eZdZdd�Zdd�Zdd�ZdS)�StreamErrorTestscCs$t�d�}|��}|�|jt�dS)zK
        Test namespace of the element representation of an error.
        r
N)r�StreamErrorr
rr�
NS_STREAMSrrrrr@s
z%StreamErrorTests.test_getElementPlaincCs*t�d�}|��}|�tt|d�j�dS�zR
        Test that the error condition element has the correct namespace.
        r
N)rr)r
r�NS_XMPP_STREAMS�getattrrrrrr�!test_getElementConditionNamespaceHs
z2StreamErrorTests.test_getElementConditionNamespacecCs(t�dd�}|��}|�t|jj�dS)�M
        Test that the error text element has the correct namespace.
        r
rN)rr)r
rr,rrrrrr�test_getElementTextNamespacePsz-StreamErrorTests.test_getElementTextNamespaceN)r%r&r'rr.r0rrrrr(>sr(c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�StanzaErrorTestsz)
    Tests for L{error.StreamError}.
    cCs*t�d�}|�d|j�|�d|j�dS)zI
        Remote Server Timeout should yield type wait, code 504.
        zremote-server-timeout�waitZ504N)r�StanzaErrorr�type�code)rrrrr�test_typeRemoteServerTimeout`s
z-StanzaErrorTests.test_typeRemoteServerTimeoutcCsDt�d�}|��}|�|jd�|�|dd�|�|dd�dS)zC
        Test getting an element for a plain stanza error.
        r
Nr4�cancelr5�501�rr3r
rrrrrrris

z%StanzaErrorTests.test_getElementPlaincCsFt�dd�}|��}|�|jd�|�|dd�|�|dd�dS)zO
        Test getting an element for a stanza error with a given type.
        r
ZauthNr4r5r8r9rrrr�test_getElementTypets
z$StanzaErrorTests.test_getElementTypecCs*t�d�}|��}|�tt|d�j�dSr+)rr3r
r�NS_XMPP_STANZASr-rrrrrr.s
z2StanzaErrorTests.test_getElementConditionNamespacecCs*tjddd�}|��}|�t|jj�dS)r/r
r)rN)rr3r
rr;rrrrrrr0�sz-StanzaErrorTests.test_getElementTextNamespacecCs�t�d�}d|d<d|d<d|d<t�d�}|�|�}|�||�|�|dd�|�|dd�|�|dd	�|�|jjd
jd�|�|jdd�|�	|j|j�dS)
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�messageZchatr4zuser1@example.com�tozuser2@example.com/resource�from�service-unavailablerrr7N)
rr#rr3Z
toResponseZassertNotIdenticalrr�nameZassertNotEqual)r�stanzarZresponserrr�test_toResponse�s


�z StanzaErrorTests.test_toResponseN)
r%r&r'�__doc__r6rr:r.r0rBrrrrr1Zs			r1c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�ParseErrorTestsz)
    Tests for L{error._parseError}.
    cCst�d�|_dS)N)Nr)rr#r)rrrr�setUp�szParseErrorTests.setUpcCs(t�|jd�}|�ddddd�|�dS)z:
        Test parsing of the empty error element.
        �errornsN)�	conditionr�textLangr")r�_parseErrorr�r�resultrrr�
test_empty�s��zParseErrorTests.test_emptycCs.|j�d�t�|jd�}|�d|d�dS)zD
        Test parsing of an error element with a condition.
        )rF�bad-requestrFrMrGN�r�
addElementrIrrJrrr�test_condition�szParseErrorTests.test_conditioncCsH|j�d�}|�d�t�|jd�}|�d|d�|�d|d�dS)z?
        Test parsing of an error element with a text.
        �rFr�testrFrNrH)rrO�
addContentrIr�rrrKrrr�	test_text�s

zParseErrorTests.test_textcCsD|j�d�}d|tdf<|�d�t�|jd�}|�d|d�dS)zW
        Test parsing of an error element with a text with a defined language.
        rQrrrRrFrHN)rrOrrSrIrrTrrr�
test_textLang�s

zParseErrorTests.test_textLangcCs.|j�d�}t�|jd�}|�||d�dS)zR
        Test parsing of an error element with an app specific condition.
        �r rGrFr"NrN�rrGrKrrr�test_appCondition�sz!ParseErrorTests.test_appConditioncCs:|j�d�|j�d�}t�|jd�}|�||d�dS)zY
        Test parsing of an error element with multiple app specific conditions.
        rW)r Z
condition2rFr"NrNrXrrr�test_appConditionMultiple�sz)ParseErrorTests.test_appConditionMultipleN)r%r&r'rCrErLrPrUrVrYrZrrrrrD�s		rDc@seZdZdd�Zdd�ZdS)�ExceptionFromStanzaTestscCs�t�d�}|�d�}|�d�|�d�}d|d<|�tdf�|�d�}d	|d
<t�|�}|�|tj�|�d|j	�|�d|j
�|�||j�|�|g|j�dS)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>
        �NrA)z!http://jabber.org/protocol/pubsubZpubsubZ
subscriptionsrr7r4r
)z(http://jabber.org/protocol/pubsub#errorsZunsupportedzretrieve-subscriptionsZfeatureN)
rr#rOr;r�exceptionFromStanza�assertIsInstancer3rrGr4r"r)rrA�prZucrKrrr�
test_basic�s





z#ExceptionFromStanzaTests.test_basiccCs�t�d�}|jddd�}|jddd�}d|d<t�|�}|�|tj�|�d	|j�|�d
|j	�|�d|j
�|�|g|j�dS)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\ZbodyzAre you there?)ZcontentrzUnable to resolve hostname.Z502r5r?r2N)rr#rOrr]r^r3rrGr4rr)rrAr_rrKrrr�test_legacys

z$ExceptionFromStanzaTests.test_legacyN)r%r&r'r`rarrrrr[�s)r[c@seZdZdd�ZdS)�ExceptionFromStreamErrorTestscCsBt�d�}|�tdf�t�|�}|�|tj�|�d|j	�dS)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#rOr,rZexceptionFromStreamErrorr^r)rrG)rrrKrrrr`;s


z(ExceptionFromStreamErrorTests.test_basicN)r%r&r'r`rrrrrb9srbN)rCZ
__future__rrZtwisted.python.compatrZ
twisted.trialrZtwisted.words.protocols.jabberrZtwisted.words.xishrrr*r,r;ZTestCaser	r(r1rDr[rbrrrr�<module>s)PHG