o
    ¼>h¨  ã                   @   sV   d Z ddlmZ ddlmZ G dd„ dejƒZG dd„ dejƒZG dd	„ d	ejƒZd
S )z2
Tests for L{twisted.words.protocols.jabber.jid}.
é    )Úunittest)Újidc                   @   sR   e Zd Zddd„Zddd„Zddd„Zdd	d
„Zddd„Zddd„Zddd„Z	dS )ÚJIDParsingTestsÚreturnNc                 C   s¸   |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t d	¡d
¡ |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t d¡d¡ |   t 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©Úself© r   ú/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/words/test/test_jabberjid.pyÚ
test_parse   s   zJIDParsingTests.test_parsec                 C   ó   |   tjtjd¡ dS )z3
        Test for failure on no host part.
        zuser@N©ÚassertRaisesr   ÚInvalidFormatr   r   r   r   r   Útest_noHost   s   zJIDParsingTests.test_noHostc                 C   r   )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   r   r   r   Útest_doubleAt%   ó   zJIDParsingTests.test_doubleAtc                 C   r   )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   r   r   r   Útest_multipleAt.   r    zJIDParsingTests.test_multipleAtc                 C   ó   |   t ddd¡d¡ dS )z@
        Test case mapping of the user part of the JID.
        ÚUsErr	   r
   r   N©r   r   Úprepr   r   r   r   Útest_prepCaseMapUser:   ó   ÿz$JIDParsingTests.test_prepCaseMapUserc                 C   r"   )z@
        Test case mapping of the host part of the JID.
        r   ÚhoSTr
   r   Nr$   r   r   r   r   Útest_prepCaseMapHostB   r'   z$JIDParsingTests.test_prepCaseMapHostc                 C   s0   |   t ddd¡d¡ |  t 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   r   r   r   Útest_prepNoCaseMapResourceJ   s   ÿÿz*JIDParsingTests.test_prepNoCaseMapResource©r   N)
Ú__name__Ú
__module__Ú__qualname__r   r   r   r!   r&   r)   r,   r   r   r   r   r      s    



	

r   c                   @   s¶   e Zd Zd%dd„Zd%dd„Zd%dd„Zd%d	d
„Zd%dd„Zd%dd„Zd%dd„Z	d%dd„Z
d%dd„Zd%dd„Zd%dd„Zd%dd„Zd%dd„Zd%dd„Zd%dd „Zd%d!d"„Zd%d#d$„ZdS )&ÚJIDTestsr   Nc                 C   s   |   ttj¡ dS )zC
        Test that using no arguments raises an exception.
        N)r   ÚRuntimeErrorr   ÚJIDr   r   r   r   Útest_noneArgumentsW   s   zJIDTests.test_noneArgumentsc                 C   s8   t  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   r3   r   r   r	   r
   ©r   Újr   r   r   Útest_attributes]   s   
zJIDTests.test_attributesc                 C   ó   t  d¡}|  d| ¡ ¡ dS )z6
        Test the extraction of the bare JID.
        r   r   N©r   r3   r   Úuserhostr5   r   r   r   Útest_userhostf   ó   
zJIDTests.test_userhostc                 C   r8   )zU
        Test the extraction of the bare JID of the full form host/resource.
        r   r	   Nr9   r5   r   r   r   Útest_userhostOnlyHostm   r<   zJIDTests.test_userhostOnlyHostc                 C   s(   t  d¡}t  d¡}|  || ¡ ¡ dS )z<
        Test getting a JID object of the bare JID.
        r   r   N)r   r3   Ú	internJIDÚassertIdenticalÚuserhostJID©r   Új1Új2r   r   r   Útest_userhostJIDt   s   

zJIDTests.test_userhostJIDc                 C   s   t  d¡}|  || ¡ ¡ dS )zW
        Test getting a JID object of the bare JID when there was no resource.
        r   N)r   r3   r?   r@   r5   r   r   r   Útest_userhostJIDNoResource|   r<   z#JIDTests.test_userhostJIDNoResourcec                 C   ó    t jdd}|  d| ¡ ¡ dS )zW
        Test giving a string representation of the JID with only a host part.
        r   ©Útupler	   N©r   r3   r   Úfullr5   r   r   r   Útest_fullHostƒ   ó   zJIDTests.test_fullHostc                 C   rF   )zU
        Test giving a string representation of the JID with host, resource.
        r   rG   r   NrI   r5   r   r   r   Útest_fullHostResourceŠ   rL   zJIDTests.test_fullHostResourcec                 C   rF   )zQ
        Test giving a string representation of the JID with user, host.
        r   rG   r   NrI   r5   r   r   r   Útest_fullUserHost‘   rL   zJIDTests.test_fullUserHostc                 C   rF   )zA
        Test giving a string representation of the JID.
        r   rG   r   NrI   r5   r   r   r   Útest_fullAll˜   rL   zJIDTests.test_fullAllc                 C   s0   t  d¡}t  d¡}|  ||¡ |  ||¡ dS ©z$
        Test JID equality.
        r   N)r   r3   ÚassertNotIdenticalr   rA   r   r   r   Útest_equalityŸ   s   

zJIDTests.test_equalityc                 C   s   t  d¡}|  |dk¡ dS rP   )r   r3   ÚassertFalser5   r   r   r   Útest_equalityWithNonJIDs¨   s   
z!JIDTests.test_equalityWithNonJIDsc                 C   s$   t  d¡}t  d¡}|  ||¡ dS )z&
        Test JID inequality.
        zuser1@host/resourcezuser2@host/resourceN©r   r3   r+   rA   r   r   r   Útest_inequality¯   ó   

zJIDTests.test_inequalityc                 C   s   t  d¡}|  |d¡ dS rP   rU   r5   r   r   r   Útest_inequalityWithNonJIDs·   s   
z#JIDTests.test_inequalityWithNonJIDsc                 C   s,   t  d¡}t  d¡}|  t|ƒt|ƒ¡ dS )z'
        Test JID hashability.
        r   N)r   r3   r   ÚhashrA   r   r   r   Útest_hashable¾   s   

zJIDTests.test_hashablec                 C   s    t jdd}|  dt|ƒ¡ dS )z6
        Test unicode representation of JIDs.
        r   rG   r   N)r   r3   r   Ústrr5   r   r   r   Útest_strÆ   rL   zJIDTests.test_strc                 C   s(   t jdd}|  dtdƒ t|ƒ¡ dS )z5
        Test representation of JID objects.
        r   rG   zJID(%s)r   N)r   r3   r   Úreprr5   r   r   r   Ú	test_reprÍ   s   zJIDTests.test_reprr-   )r.   r/   r0   r4   r7   r;   r=   rD   rE   rK   rM   rN   rO   rR   rT   rV   rX   rZ   r\   r^   r   r   r   r   r1   V   s$    


	








	



r1   c                   @   s   e Zd Zddd„ZdS )ÚInternJIDTestsr   Nc                 C   s$   t  d¡}t  d¡}|  ||¡ dS )zD
        Test that two interned JIDs yield the same object.
        r   N)r   r>   r?   rA   r   r   r   Útest_identityÖ   rW   zInternJIDTests.test_identityr-   )r.   r/   r0   r`   r   r   r   r   r_   Õ   s    r_   N)	Ú__doc__Útwisted.trialr   Útwisted.words.protocols.jabberr   ÚTestCaser   r1   r_   r   r   r   r   Ú<module>   s   J