
    Vh                         d Z ddlmZ ddlmZ  G d dej
                        Z G d dej
                        Z G d d	ej
                        Zy
)z2
Tests for L{twisted.words.protocols.jabber.jid}.
    )unittest)jidc                   D    e Zd Zd	dZd	dZd	dZd	dZd	dZd	dZd	dZ	y)
JIDParsingTestsNc                    | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d	      d
       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y)z/
        Test different forms of JIDs.
        user@host/resourceuserhostresource	user@hostr
   r   Nr   Nr   Nhost/resourceNr   r   zfoo/bar@baz)Nfoobar@bazzboo@foo/bar@baz)boor   r   zboo@foo/bar/baz)r   r   zbar/bazzboo/foo@bar@baz)Nr   zfoo@bar@bazzboo/foo/bar)Nr   zfoo/barzboo//foo)Nr   z/fooN)assertEqualr   parseselfs    Q/home/dcms/DCMS/lib/python3.12/site-packages/twisted/words/test/test_jabberjid.py
test_parsezJIDParsingTests.test_parse   s   
 	#78:VW;/1GH6*,@A?35OP 	=13KL#457PQ#457PQ#457ST=13KL:.0EF    c                 b    | j                  t        j                  t        j                  d       y)z3
        Test for failure on no host part.
        zuser@NassertRaisesr   InvalidFormatr   r   s    r   test_noHostzJIDParsingTests.test_noHost   s      	#++SYY@r   c                 b    | j                  t        j                  t        j                  d       y)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@@hostNr   r   s    r   test_doubleAtzJIDParsingTests.test_doubleAt%   s      	#++SYYEr   c                 b    | j                  t        j                  t        j                  d       y)z
        Test for failure on two @ signs.

        This should fail because @ is not a valid character for the host
        part of the JID.
        zuser@host@hostNr   r   s    r   test_multipleAtzJIDParsingTests.test_multipleAt.   s!     	#++SYY8HIr   c                 R    | j                  t        j                  ddd      d       y)z@
        Test case mapping of the user part of the JID.
        UsErr   r   r	   Nr   r   prepr   s    r   test_prepCaseMapUserz$JIDParsingTests.test_prepCaseMapUser:   %     	HHVVZ02N	
r   c                 R    | j                  t        j                  ddd      d       y)z@
        Test case mapping of the host part of the JID.
        r
   hoSTr   r	   Nr'   r   s    r   test_prepCaseMapHostz$JIDParsingTests.test_prepCaseMapHostB   r*   r   c                     | j                  t        j                  ddd      d       | j                  t        j                  ddd      d       y)zH
        Test no case mapping of the resourcce part of the JID.
        r
   r,   r   r	   r   ResourceN)r   r   r(   assertNotEqualr   s    r   test_prepNoCaseMapResourcez*JIDParsingTests.test_prepNoCaseMapResourceJ   sH     	HHVVZ02N	
 	HHVVZ02N	
r   returnN)
__name__
__module____qualname__r   r    r"   r$   r)   r-   r1    r   r   r   r      s)    G$AFJ

	
r   r   c                       e Zd ZddZddZddZddZddZddZddZ	dd	Z
dd
ZddZddZddZddZddZddZddZddZy)JIDTestsNc                 L    | j                  t        t        j                         y)zC
        Test that using no arguments raises an exception.
        N)r   RuntimeErrorr   JIDr   s    r   test_noneArgumentszJIDTests.test_noneArgumentsW   s     	,0r   c                     t        j                  d      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       y)zI
        Test that the attributes correspond with the JID parts.
        r   r
   r   r   N)r   r<   r   r
   r   r   r   js     r   test_attributeszJIDTests.test_attributes]   sO     GG()((Z0r   c                 n    t        j                  d      }| j                  d|j                                y)z6
        Test the extraction of the bare JID.
        r   r   Nr   r<   r   userhostr?   s     r   test_userhostzJIDTests.test_userhostf   s)     GG()ajjl3r   c                 n    t        j                  d      }| j                  d|j                                y)zU
        Test the extraction of the bare JID of the full form host/resource.
        r   r   NrC   r?   s     r   test_userhostOnlyHostzJIDTests.test_userhostOnlyHostm   s(     GGO$.r   c                     t        j                  d      }t        j                  d      }| j                  ||j	                                y)z<
        Test getting a JID object of the bare JID.
        r   r   N)r   r<   	internJIDassertIdenticaluserhostJIDr   j1j2s      r   test_userhostJIDzJIDTests.test_userhostJIDt   s8     WW)*]];'R!12r   c                 n    t        j                  d      }| j                  ||j                                y)zW
        Test getting a JID object of the bare JID when there was no resource.
        r   N)r   r<   rJ   rK   r?   s     r   test_userhostJIDNoResourcez#JIDTests.test_userhostJIDNoResource|   s(     GGK Q0r   c                 p    t        j                  d      }| j                  d|j                                y)zW
        Test giving a string representation of the JID with only a host part.
        r   tupler   Nr   r<   r   fullr?   s     r   test_fullHostzJIDTests.test_fullHost   s)     GG./*r   c                 p    t        j                  d      }| j                  d|j                                y)zU
        Test giving a string representation of the JID with host, resource.
        r   rS   r   NrU   r?   s     r   test_fullHostResourcezJIDTests.test_fullHostResource   s)     GG45!&&(3r   c                 p    t        j                  d      }| j                  d|j                                y)zQ
        Test giving a string representation of the JID with user, host.
        r   rS   r   NrU   r?   s     r   test_fullUserHostzJIDTests.test_fullUserHost   s)     GG01affh/r   c                 p    t        j                  d      }| j                  d|j                                y)zA
        Test giving a string representation of the JID.
        r	   rS   r   NrU   r?   s     r   test_fullAllzJIDTests.test_fullAll   s*     GG67-qvvx8r   c                     t        j                  d      }t        j                  d      }| j                  ||       | j                  ||       yz$
        Test JID equality.
        r   N)r   r<   assertNotIdenticalr   rL   s      r   test_equalityzJIDTests.test_equality   sB     WW)*WW)*B'R r   c                 V    t        j                  d      }| j                  |dk(         yr_   )r   r<   assertFalser?   s     r   test_equalityWithNonJIDsz!JIDTests.test_equalityWithNonJIDs   s'     GG()223r   c                 |    t        j                  d      }t        j                  d      }| j                  ||       y)z&
        Test JID inequality.
        zuser1@host/resourcezuser2@host/resourceNr   r<   r0   rL   s      r   test_inequalityzJIDTests.test_inequality   s2     WW*+WW*+B#r   c                 R    t        j                  d      }| j                  |d       yr_   rf   r?   s     r   test_inequalityWithNonJIDsz#JIDTests.test_inequalityWithNonJIDs   s$     GG()A34r   c                     t        j                  d      }t        j                  d      }| j                  t        |      t        |             y)z'
        Test JID hashability.
        r   N)r   r<   r   hashrL   s      r   test_hashablezJIDTests.test_hashable   s:     WW)*WW)*b48,r   c                 f    t        j                  d      }| j                  dt        |             y)z6
        Test unicode representation of JIDs.
        r	   rS   r   N)r   r<   r   strr?   s     r   test_strzJIDTests.test_str   s(     GG67-s1v6r   c                 ~    t        j                  d      }| j                  dt        d      z  t        |             y)z5
        Test representation of JID objects.
        r	   rS   zJID(%s)r   N)r   r<   r   reprr?   s     r   	test_reprzJIDTests.test_repr   s2     GG67T*>%??aIr   r2   )r4   r5   r6   r=   rA   rE   rG   rO   rQ   rW   rY   r[   r]   ra   rd   rg   ri   rl   ro   rr   r7   r   r   r9   r9   V   sX    114/31+409!4$5-7Jr   r9   c                       e Zd ZddZy)InternJIDTestsNc                 |    t        j                  d      }t        j                  d      }| j                  ||       y)zD
        Test that two interned JIDs yield the same object.
        r   N)r   rI   rJ   rL   s      r   test_identityzInternJIDTests.test_identity   s0     ]];']];'R$r   r2   )r4   r5   r6   rv   r7   r   r   rt   rt      s    %r   rt   N)	__doc__twisted.trialr   twisted.words.protocols.jabberr   TestCaser   r9   rt   r7   r   r   <module>r{      sP    # .G
h'' G
T|Jx   |J~%X&& %r   