
    Yf                         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d
S )z2
Tests for L{twisted.words.protocols.jabber.jid}.
    )unittest)jidc                   F    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S )JIDParsingTestsreturnNc                 &   |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d	          d
           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           |                      t          j        d          d           dS )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    S/var/www/html/env/lib/python3.11/site-packages/twisted/words/test/test_jabberjid.py
test_parsezJIDParsingTests.test_parse   sZ   
 	#788:VWWW;//1GHHH6**,@AAA?335OPPP 	=113KLLL#4557PQQQ#4557PQQQ#4557STTT=113KLLL:..0EFFFFF    c                 \    |                      t          j        t          j        d           dS )z3
        Test for failure on no host part.
        zuser@NassertRaisesr   InvalidFormatr   r   s    r   test_noHostzJIDParsingTests.test_noHost   s'     	#+SY@@@@@r   c                 \    |                      t          j        t          j        d           dS )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'     	#+SYEEEEEr   c                 \    |                      t          j        t          j        d           dS )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(     	#+SY8HIIIIIr   c                 Z    |                      t          j        ddd          d           dS )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:   :     	HVVZ002N	
 	
 	
 	
 	
r   c                 Z    |                      t          j        ddd          d           dS )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                     |                      t          j        ddd          d           |                     t          j        ddd          d           dS )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     	HVVZ002N	
 	
 	
 	HVVZ002N	
 	
 	
 	
 	
r   r   N)
__name__
__module____qualname__r   r!   r#   r%   r*   r.   r2    r   r   r   r      s        G G G G$A A A AF F F FJ J J 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dS )JIDTestsr   Nc                 P    |                      t          t          j                   dS )zC
        Test that using no arguments raises an exception.
        N)r   RuntimeErrorr   JIDr   s    r   test_noneArgumentszJIDTests.test_noneArgumentsW   s"     	,00000r   c                     t          j        d          }|                     |j        d           |                     |j        d           |                     |j        d           dS )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]   sb     G())((((((Z00000r   c                 ~    t          j        d          }|                     d|                                           dS )z6
        Test the extraction of the bare JID.
        r	   r   Nr   r<   r   userhostr?   s     r   test_userhostzJIDTests.test_userhostf   s8     G())ajjll33333r   c                 ~    t          j        d          }|                     d|                                           dS )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   s7     GO$$.....r   c                     t          j        d          }t          j        d          }|                     ||                                           dS )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   sI     W)**];''R!1!122222r   c                 ~    t          j        d          }|                     ||                                           dS )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|   s7     GK  Q00000r   c                     t          j        d          }|                     d|                                           dS )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;     G.///*****r   c                     t          j        d          }|                     d|                                           dS )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;     G4555!&&((33333r   c                     t          j        d          }|                     d|                                           dS )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;     G0111affhh/////r   c                     t          j        d          }|                     d|                                           dS )zA
        Test giving a string representation of the JID.
        r
   rS   r	   NrU   r?   s     r   test_fullAllzJIDTests.test_fullAll   s<     G6777-qvvxx88888r   c                     t          j        d          }t          j        d          }|                     ||           |                     ||           dS z$
        Test JID equality.
        r	   N)r   r<   assertNotIdenticalr   rL   s      r   test_equalityzJIDTests.test_equality   sV     W)**W)**B'''R     r   c                 `    t          j        d          }|                     |dk               dS r_   )r   r<   assertFalser?   s     r   test_equalityWithNonJIDsz!JIDTests.test_equalityWithNonJIDs   s4     G())2233333r   c                     t          j        d          }t          j        d          }|                     ||           dS )z&
        Test JID inequality.
        zuser1@host/resourcezuser2@host/resourceNr   r<   r1   rL   s      r   test_inequalityzJIDTests.test_inequality   s@     W*++W*++B#####r   c                 Z    t          j        d          }|                     |d           dS r_   rf   r?   s     r   test_inequalityWithNonJIDsz#JIDTests.test_inequalityWithNonJIDs   s1     G())A344444r   c                     t          j        d          }t          j        d          }|                     t          |          t          |                     dS )z'
        Test JID hashability.
        r	   N)r   r<   r   hashrL   s      r   test_hashablezJIDTests.test_hashable   sL     W)**W)**b488,,,,,r   c                 v    t          j        d          }|                     dt          |                     dS )z6
        Test unicode representation of JIDs.
        r
   rS   r	   N)r   r<   r   strr?   s     r   test_strzJIDTests.test_str   s:     G6777-s1vv66666r   c                     t          j        d          }|                     dt          d          z  t          |                     dS )z5
        Test representation of JID objects.
        r
   rS   zJID(%s)r	   N)r   r<   r   reprr?   s     r   	test_reprzJIDTests.test_repr   sG     G6777T*>%?%??aIIIIIr   r3   )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   sn       1 1 1 11 1 1 14 4 4 4/ / / /3 3 3 31 1 1 1+ + + +4 4 4 40 0 0 09 9 9 9! ! ! !4 4 4 4$ $ $ $5 5 5 5- - - -7 7 7 7J J J J J Jr   r9   c                       e Zd ZddZdS )InternJIDTestsr   Nc                     t          j        d          }t          j        d          }|                     ||           dS )zD
        Test that two interned JIDs yield the same object.
        r   N)r   rI   rJ   rL   s      r   test_identityzInternJIDTests.test_identity   s>     ];''];''R$$$$$r   r3   )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{      s     # " " " " " . . . . . .G
 G
 G
 G
 G
h' G
 G
 G
T|J |J |J |J |Jx  |J |J |J~% % % % %X& % % % % %r   