Ϫf -8dZddlmZddlmZddlmZdZdZdZ dZ Gd d ejZ Gd d ejZ Gd dejZGddejZGddejZGddejZy)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,eZdZddZddZddZddZy)BaseErrorTestsNctjd}|j}|j|jd|j t |jdy)z< Test getting an element for a plain error. feature-not-implementedN)r BaseError getElementassertIdenticaluri assertEquallenchildrenselfeelements E/usr/lib/python3/dist-packages/twisted/words/test/test_jabbererror.pytest_getElementPlainz#BaseErrorTests.test_getElementPlainsM OO5 6,,. W[[$/ W--.2cFtjdd}|j}|jt |j d|jt |jd|j|jjtdfdy)zC Test getting an element for an error with a text. r textlangN) rr r rrrstrr getAttributeNS_XMLrs rtest_getElementTextz"BaseErrorTests.test_getElementTextsx OO5v >,,. W--.2 W\\*F3 22FF3CDdKrc0tjddd}|j}|jt |j d|jt |jd|j|jtdfdy)zP Test getting an element for an error with a text and language. r ren_USrrN) rr r rrrrrr rs rtest_getElementTextLangz&BaseErrorTests.test_getElementTextLang'st OO5vw G,,. W--.2 W\\*F3 vv&67Arctjd}tjd|}|j }|j t |jd|j |j|y)zV Test getting an element for an error with an app specific condition. )testnsmyerrorr ) appConditionrN) rElementrr r rrrr')racrrs rtest_getElementAppConditionz*BaseErrorTests.test_getElementAppCondition1s^^^1 2 OO5B G,,. W--.2 "-rreturnN)__name__ __module__ __qualname__rr!r$r+rrrrs3LB.rrc$eZdZddZddZddZy)StreamErrorTestsNctjd}|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,,. j1rctjd}|j}|jtt |dj yzR Test that the error condition element has the correct namespace. r N)rr5r rNS_XMPP_STREAMSgetattrrrs r!test_getElementConditionNamespacez2StreamErrorTests.test_getElementConditionNamespaceEA   7 8,,.  WW.GHLL rctjdd}|j}|jt|j j y)M Test that the error text element has the correct namespace. r rN)rr5r rr9rrrs rtest_getElementTextNamespacez-StreamErrorTests.test_getElementTextNamespaceOs<   7 @,,. ',,*:*:;rr,)r.r/r0rr;r?r1rrr3r3<s2 r r)rN)rrEr rrQrrrs rr?z-StanzaErrorTests.test_getElementTextNamespaces<   7f 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|jy ) 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:clientmessagechatrFzuser1@example.comtozuser2@example.com/resourcefromservice-unavailablerrrJN) rr)rrE toResponseassertNotIdenticalrrnameassertNotEqual)rstanzarresponses rtest_toResponsez StanzaErrorTests.test_toResponses <=v*t 5v   3 4<<' &1 &)+>? $)EF &)73 00388:OP /: FOOX->->?rr,) r.r/r0__doc__rHrrOr;r?r_r1rrrArAXs&(11 <@rrAcHeZdZdZd dZd dZd dZd dZd dZd dZ d d Z y) ParseErrorTestsz) Tests for L{error._parseError}. Nc8tjd|_y)N)Nr)rr)r)rs rsetUpzParseErrorTests.setUps^^O4 rcrtj|jd}|jddddd|y)z: Test parsing of the empty error element. errornsN) conditionrtextLangr()r _parseErrorrrresults r test_emptyzParseErrorTests.test_emptys8""4::y9 $PT U  rc|jjdtj|jd}|jd|dy)zD Test parsing of an error element with a condition. )rf bad-requestrfrnrgNr addElementrirrjs rtest_conditionzParseErrorTests.test_conditionsB 89""4::y9 {(;$:;rc|jjd|jjd}tj|jd}|j||dy)zY Test parsing of an error element with multiple app specific conditions. r{)r& condition2rfr(Nror|s rtest_appConditionMultiplez)ParseErrorTests.test_appConditionMultiplesW 56JJ))*BC ""4::y9 F>$:;rr,) r.r/r0r`rdrlrqrwryr}rr1rrrbrbs*5 =36< Nr])z!http://jabber.org/protocol/pubsubpubsub subscriptionsrrJrFr )z(http://jabber.org/protocol/pubsub#errors unsupportedzretrieve-subscriptionsfeatureN) rr)rprQrexceptionFromStanzaassertIsInstancerErrgrFr(r)rr]prucrks r test_basicz#ExceptionFromStanzaTests.test_basics0 01   M N _%   g &&  o'@AB \\U V09 **62 fe&7&78 2F4D4DE 6;;/ V001 !foo.rctjd}|jdd}|jdd}d|d<tj|}|j |tj |jd |j|jd |j|jd|j|j|g|jy ) 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:: Are you there? Unable to resolve hostname. rbodyzAre you there?)contentrzUnable to resolve hostname.502rGrXrCN) rr)rprrrrErrgrFrr)rr]rrrks r test_legacyz$ExceptionFromStanzaTests.test_legacy s  01   f.>  ?   g/L  M& **62 fe&7&78 .0@0@A - 6 D !foo.rr,)r.r/r0rrr1rrrrs &/P/rrceZdZddZy)ExceptionFromStreamErrorTestsNctjd}|jtdft j |}|j |tj|jd|jy)ac Test basic operations of exceptionFromStreamError. Given a realistic stream error, check if a sane exception is returned. Using this error:: )rrzxml-not-well-formedN) rr)rpr9rexceptionFromStreamErrorrr5rrg)rrrks rrz(ExceptionFromStreamErrorTests.test_basic)sb NNH I o'<=>//2 fe&7&78 .0@0@Arr,)r.r/r0rr1rrrr(sBrrN)r` twisted.trialrtwisted.words.protocols.jabberrtwisted.words.xishrr r6r9rQTestCaserr3rArbrrr1rrrs #0% / / 77&.X&&&.R