ϪfdZddlmZddlmZGddej ZGddej ZGdd ej Zy ) z2 Tests for L{twisted.words.protocols.jabber.jid}. )unittest)jidcDeZdZd dZd dZd dZd dZd dZd dZd dZ y) JIDParsingTestsNc|jtjdd|jtjdd|jtjdd|jtjdd|jtjd d |jtjd d |jtjd d|jtjdd|jtjdd|jtjddy)z/ Test different forms of JIDs. user@host/resourceuserhostresource user@hostr r Nr Nr N host/resourceNr r z foo/bar@baz)Nfoobar@bazzboo@foo/bar@baz)boorrzboo@foo/bar/baz)rrzbar/bazzboo/foo@bar@baz)Nrz foo@bar@bazz boo/foo/bar)Nrzfoo/barzboo//foo)Nrz/fooN) assertEqualrparseselfs C/usr/lib/python3/dist-packages/twisted/words/test/test_jabberjid.py test_parsezJIDParsingTests.test_parse s #78:VW ;/1GH 6*,@A ?35OP =13KL #457PQ #457PQ #457ST =13KL :.0EFcb|jtjtjdy)z3 Test for failure on no host part. zuser@N assertRaisesr InvalidFormatrrs r test_noHostzJIDParsingTests.test_noHosts  #++SYY@rcb|jtjtjdy)z Test for failure on double @ signs. This should fail because @ is not a valid character for the host part of the JID. z user@@hostNrrs r test_doubleAtzJIDParsingTests.test_doubleAt%s  #++SYY Ercb|jtjtjdy)z Test for failure on two @ signs. This should fail because @ is not a valid character for the host part of the JID. zuser@host@hostNrrs rtest_multipleAtzJIDParsingTests.test_multipleAt.s! #++SYY8HIrcR|jtjddddy)z@ Test case mapping of the user part of the JID. UsErr r r Nrrpreprs rtest_prepCaseMapUserz$JIDParsingTests.test_prepCaseMapUser:%  HHVVZ 02N rcR|jtjddddy)z@ Test case mapping of the host part of the JID. r hoSTr r Nr'rs rtest_prepCaseMapHostz$JIDParsingTests.test_prepCaseMapHostBr*rc|jtjdddd|jtjddddy)zH Test no case mapping of the resourcce part of the JID. r r,r r r ResourceN)rrr(assertNotEqualrs rtest_prepNoCaseMapResourcez*JIDParsingTests.test_prepNoCaseMapResourceJsH  HHVVZ 02N   HHVVZ 02N rreturnN) __name__ __module__ __qualname__rr r"r$r)r-r1rrrr s)G$A FJ    rrceZdZddZddZddZddZddZddZddZ dd Z dd Z dd Z dd Z dd ZddZddZddZddZddZy)JIDTestsNcL|jttjy)zC Test that using no arguments raises an exception. N)r RuntimeErrorrJIDrs rtest_noneArgumentszJIDTests.test_noneArgumentsWs ,0rctjd}|j|jd|j|jd|j|j dy)zI Test that the attributes correspond with the JID parts. rr r r N)rr<rr r r rjs rtest_attributeszJIDTests.test_attributes]sO GG( ) ( ( Z0rcntjd}|jd|jy)z6 Test the extraction of the bare JID. rr Nrr<ruserhostr?s r test_userhostzJIDTests.test_userhostfs) GG( ) ajjl3rcntjd}|jd|jy)zU Test the extraction of the bare JID of the full form host/resource. rr NrCr?s rtest_userhostOnlyHostzJIDTests.test_userhostOnlyHostms( GGO $ .rctjd}tjd}|j||j y)z< Test getting a JID object of the bare JID. rr N)rr< internJIDassertIdentical userhostJIDrj1j2s rtest_userhostJIDzJIDTests.test_userhostJIDts8WW) * ]]; ' R!12rcntjd}|j||jy)zW Test getting a JID object of the bare JID when there was no resource. r N)rr<rJrKr?s rtest_userhostJIDNoResourcez#JIDTests.test_userhostJIDNoResource|s( GGK  Q 0rcptjd}|jd|jy)zW Test giving a string representation of the JID with only a host part. rtupler Nrr<rfullr?s r test_fullHostzJIDTests.test_fullHosts) GG. / *rcptjd}|jd|jy)zU Test giving a string representation of the JID with host, resource. rrSrNrUr?s rtest_fullHostResourcezJIDTests.test_fullHostResources) GG4 5 !&&(3rcptjd}|jd|jy)zQ Test giving a string representation of the JID with user, host. rrSr NrUr?s rtest_fullUserHostzJIDTests.test_fullUserHosts) GG0 1 affh/rcptjd}|jd|jy)zA Test giving a string representation of the JID. r rSrNrUr?s r test_fullAllzJIDTests.test_fullAlls* GG6 7 -qvvx8rctjd}tjd}|j|||j||yz$ Test JID equality. rN)rr<assertNotIdenticalrrLs r test_equalityzJIDTests.test_equalitysBWW) * WW) * B' R rcVtjd}|j|dk(yr_)rr< assertFalser?s rtest_equalityWithNonJIDsz!JIDTests.test_equalityWithNonJIDss' GG( ) 223rc|tjd}tjd}|j||y)z& Test JID inequality. zuser1@host/resourcezuser2@host/resourceNrr<r0rLs rtest_inequalityzJIDTests.test_inequalitys2WW* + WW* + B#rcRtjd}|j|dyr_rfr?s rtest_inequalityWithNonJIDsz#JIDTests.test_inequalityWithNonJIDss$ GG( ) A34rctjd}tjd}|jt|t|y)z' Test JID hashability. rN)rr<rhashrLs r test_hashablezJIDTests.test_hashables:WW) * WW) * b48,rcftjd}|jdt|y)z6 Test unicode representation of JIDs. r rSrN)rr<rstrr?s rtest_strzJIDTests.test_strs( GG6 7 -s1v6rc~tjd}|jdtdzt|y)z5 Test representation of JID objects. r rSzJID(%s)rN)rr<rreprr?s r test_reprzJIDTests.test_reprs2 GG6 7 T*>%??aIrr2)r4r5r6r=rArErGrOrQrWrYr[r]rardrgrirlrorrr7rrr9r9VsX1 14/31+409!4$5-7Jrr9ceZdZddZy)InternJIDTestsNc|tjd}tjd}|j||y)zD Test that two interned JIDs yield the same object. r N)rrIrJrLs r test_identityzInternJIDTests.test_identitys0]]; ' ]]; ' R$rr2)r4r5r6rvr7rrrtrts%rrtN) __doc__ twisted.trialrtwisted.words.protocols.jabberrTestCaserr9rtr7rrr{sP#.G h''G T|Jx  |J~%X&&%r