%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/words/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/words/test/__pycache__/test_ircsupport.cpython-312.pyc

�

Ϫ�f�)���dZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
Gd�de�ZGd	�d
e�ZGd�de�ZGd
�de
�Zy)z+
Tests for L{twisted.words.im.ircsupport}.
�)�StringTransport)�ChatUI�Conversation�GroupConversation)�
IRCAccount�IRCProto)�OfflineError)�IRCTestCasec��eZdZd�Zd�Zy)�StubConversationc��y�N���selfs �D/usr/lib/python3/dist-packages/twisted/words/test/test_ircsupport.py�showzStubConversation.show����c� �||_||_yr)�message�metadata)rrrs   r�showMessagezStubConversation.showMessages����� ��
rN)�__name__�
__module__�__qualname__rrrrrrrs��
�!rrc� �eZdZd�Zd�Zdd�Zy)�StubGroupConversationc� �||_||_yr)�topic�
topicSetBy)rr �nicknames   r�setTopiczStubGroupConversation.setTopics����
�"��rc��yrrrs rrzStubGroupConversation.showrrNc�.�||_||_||_yr)r�text)r�senderr&rs    r�showGroupMessagez&StubGroupConversation.showGroupMessage s�� ��
���	� ��
rr)rrrr#rr(rrrrrs��#�
�!rrc�$�eZdZedfd�Zedfd�Zy)�
StubChatUIrc�2�tj||||�Sr�r�getGroupConversation�r�group�Class�
stayHiddens    r�getConversationzStubChatUI.getConversation'����*�*�4���z�J�Jrc�2�tj||||�Srr,r.s    rr-zStubChatUI.getGroupConversation*r3rN)rrrrr2rr-rrrr*r*&s��+;��K�1F�RS�Krr*c��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
dd
�Zdd�Zdd�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zy)�
IRCProtoTestsz 
    Tests for L{IRCProto}.
    Nc��tdddddd�|_t|jt�d�|_t�|_y)NzSome accountF�alicezexample.comi)r�accountrr*�protor�	transportrs r�setUpzIRCProtoTests.setUp3s=��!��E�7�D�-��
����d�l�l�J�L�$�?��
�(�*��rc��|jj|j�|j|jj	�d�y)z�
        When L{IRCProto} is connected to a transport, it sends I{NICK} and
        I{USER} commands with the username from the account object.
        z1NICK alice
USER alice foo bar :Twisted-IM user
N)r:�makeConnectionr;�assertEqualBufferValue�valuers r�
test_loginzIRCProtoTests.test_login:s;��
	
�
�
�!�!�$�.�.�1��#�#��N�N� � �"�F�	
rc���d|j_|jj|j�|j|jj
�d�y)z�
        If created with an account with a password, L{IRCProto} sends a
        I{PASS} command before the I{NICK} and I{USER} commands.
        �secretz>PASS secret
NICK alice
USER alice foo bar :Twisted-IM user
N)r9�passwordr:r>r;r?r@rs r�test_authenticatezIRCProtoTests.test_authenticateEsI��
!)������
�
�!�!�$�.�.�1��#�#��N�N� � �"�
6�	
rc���ddg|j_|jj|j�|j|jj
�d�y)z�
        If created with an account with a list of channels, L{IRCProto}
        joins each of those channels after registering.
        �#fooz#barzGNICK alice
USER alice foo bar :Twisted-IM user
JOIN #foo
JOIN #bar
N)r9�channelsr:r>r;r?r@rs r�
test_channelszIRCProtoTests.test_channelsSsN��
"(�� 0������
�
�!�!�$�.�.�1��#�#��N�N� � �"�
�	
rc���|jj|j�|jjd�|j	d|jj
j
d��y)z�
        L{IRCProto} can interpret I{ISUPPORT} (I{005}) messages from the server
        and reflect their information in its C{supported} attribute.
        z3:irc.example.com 005 alice MODES=4 CHANLIMIT=#:20
��MODESN)r:r>r;�dataReceived�assertEqual�	supported�
getFeaturers r�
test_isupportzIRCProtoTests.test_isupportbsR��
	
�
�
�!�!�$�.�.�1��
�
��� W�X�����D�J�J�0�0�;�;�G�D�Erc��|jj|j�|jjd�|jjd�|jjd�|jjd�|j	d|jj
�|j
d|jj
�y)zB
        IRC NICK command changes the nickname of a user.
        z:alice JOIN #group1
�:alice1 JOIN #group1
z:alice1 NICK newnick
z:alice3 NICK newnick3
�newnick�alice1N�r:r>r;rM�assertIn�	_ingroups�assertNotInrs r�	test_nickzIRCProtoTests.test_nickks���	
�
�
�!�!�$�.�.�1��
�
��� 9�:��
�
��� :�;��
�
��� :�;��
�
��� ;�<��
�
�i����!5�!5�6�����4�:�:�#7�#7�8rc�n�|jj|j�|jjd�|j	d|jj
d�|j
d|jj
d�|jjd�|jjd�|jjd�|j
d|jj
d�|j
d|jj
d�y)	zF
        IRC PART command removes a user from an IRC channel.
        rS�group1rU�group2z:alice PART #group1
z:alice1 PART #group1
z:alice1 PART #group2
NrVrs r�	test_partzIRCProtoTests.test_partws���	
�
�
�!�!�$�.�.�1��
�
��� :�;��
�
�h��
�
� 4� 4�X� >�?�����4�:�:�#7�#7��#A�B��
�
��� 9�:��
�
��� :�;��
�
��� :�;�����4�:�:�#7�#7��#A�B�����4�:�:�#7�#7��#A�Brc��|jj|j�|jjd�|j	d|jj
d�|j
d|jj
d�|jjd�|j	d|jj
d�|jjd�|jt|jj
d�dk(�|jjd	�y
)zH
        IRC QUIT command removes a user from all IRC channels.
        rSr\rUr]z:alice1 JOIN #group3
�group3z:alice1 QUIT
rz:alice3 QUIT
N)	r:r>r;rMrWrXrY�
assertTrue�lenrs r�	test_quitzIRCProtoTests.test_quit�s���	
�
�
�!�!�$�.�.�1��
�
��� :�;��
�
�h��
�
� 4� 4�X� >�?�����4�:�:�#7�#7��#A�B��
�
��� :�;��
�
�h��
�
� 4� 4�X� >�?��
�
��� 2�3�����D�J�J�0�0��:�;�q�@�A��
�
��� 2�3rc�`�|jj|j�|jjd�|jjd�|jj	d�}|j|jd�|j|jd�y)zH
        IRC TOPIC command changes the topic of an IRC channel.
        rSz :alice1 TOPIC #group1 newtopic
r\�newtopicrUN)r:r>r;rMr-rNr r!)r�groupConversations  r�
test_topiczIRCProtoTests.test_topic�s���	
�
�
�!�!�$�.�.�1��
�
��� :�;��
�
��� D�E� �J�J�;�;�H�E�����*�0�0�*�=����*�5�5�x�@rc�f�|jj|j�|jjd�|jjj|jj
d��}|j|jd�|jjd�|jjd�}|j|jd�|jjd�|jjd�|jjd	�}|jt|d
��|jjj|jj
d��}|jt|d��y)
zG
        PRIVMSG sends a private message to a user or channel.
        z#:alice1 PRIVMSG t2 test_message_1
rU�test_message_1z(:alice1 PRIVMSG #group1 test_message_2
r\�test_message_2r8z$:alice PRIVMSG #foo test_message_3
�foor&rN�r:r>r;rM�chatr2�	getPersonrNrr-r&�setNick�assertFalse�hasattr�r�conversationrfs   r�test_privmsgzIRCProtoTests.test_privmsg�s7��	
�
�
�!�!�$�.�.�1��
�
��� G�H��z�z���6�6�t�z�z�7K�7K�H�7U�V������-�-�/?�@��
�
��� L�M� �J�J�;�;�H�E�����*�/�/�1A�B��
�
���7�#��
�
��� H�I� �J�J�;�;�E�B������!2�F�;�<��z�z���6�6�t�z�z�7K�7K�G�7T�U�������y�9�:rc�f�|jj|j�|jjd�|jjj|jj
d��}|j|jd�|jjd�|jjd�}|j|jd�|jjd�|jjd�|jjd	�}|jt|d
��|jjj|jj
d��}|jt|d��y)
z3
        CTCP ACTION to a user or channel.
        z):alice1 PRIVMSG alice1 :ACTION smiles
rU�smilesz*:alice1 PRIVMSG #group1 :ACTION laughs
r\�laughsr8z(:alice PRIVMSG #group1 :ACTION cries
rkr&rNrlrrs   r�test_actionzIRCProtoTests.test_action�s5��	
�
�
�!�!�$�.�.�1��
�
��� Q�R��z�z���6�6�t�z�z�7K�7K�H�7U�V������-�-�x�8��
�
��� R�S� �J�J�;�;�H�E�����*�/�/��:��
�
���7�#��
�
��� P�Q� �J�J�;�;�E�B������!2�F�;�<��z�z���6�6�t�z�z�7K�7K�G�7T�U�������y�9�:rc�8�|jj|j�|jjd�dgdgdgdgdgd�}dgd�i}|j	||jj
�|j	||jj�|jjd�|j	i|jj�|jjd�}|j	|d|j�y)z�
        RPL_NAMREPLY server response (353) lists all the users in a channel.
        RPL_ENDOFNAMES server response (363) is sent at the end of RPL_NAMREPLY
        to indicate that there are no more names.
        z>:example.com 353 z3p = #bnl :pSwede Dan- SkOyg @MrOp +MrPlus
�bnl)�Dan-�pSwede�SkOyg�MrOp�MrPlus)r|r{r}r~rz1:example.com 366 alice #bnl :End of /NAMES list
N)	r:r>r;rMrNrX�_namrepliesr-�members)r�expectedInGroups�expectedNamRepliesrfs    r�test_rplNamreplyzIRCProtoTests.test_rplNamreply�s���	
�
�
�!�!�$�.�.�1��
�
���N�	
��G��g��W��G��g�
��$�%R�S�����)�4�:�:�+?�+?�@����+�T�Z�Z�-C�-C�D��
�
��� U�V�����T�Z�Z�3�3�4� �J�J�;�;�E�B�����+�E�2�4E�4M�4M�Nrc���|jj|j�|jjd�|j	d|jj
d�y)z[
        RPL_TOPIC server response (332) is sent when a channel's topic is changed
        z1:example.com 332 alice, #foo :Some random topic
zSome random topicrkN)r:r>r;rMrN�_topicsrs r�
test_rplTopiczIRCProtoTests.test_rplTopic�sM��	
�
�
�!�!�$�.�.�1��
�
��� U�V����,�d�j�j�.@�.@��.G�Hrc�~�|jj|j�|jjd�}|j	t
|jd�|j|j_|jj�|j
d�|j|jjj�d�|jj�|j
dddi�|j|jjj�d�y	)
z*
        L{IRCPerson.sendMessage}
        r8�Some message�Some message 2sPRIVMSG alice :Some message 2
rv�style�emotes PRIVMSG alice :ACTION smiles
N)
r:r>r;rn�assertRaisesr	�sendMessager9�client�clearrN�io�getvalue)r�persons  r�test_sendMessagezIRCProtoTests.test_sendMessage�s���	
�
�
�!�!�$�.�.�1����%�%�g�.�����,��(:�(:�N�K� $�
�
��������������+�,�����N�N���&�&�(�*N�	
�	
���������8�g�w�%7�8�����N�N���&�&�(�*U�	
rc��|jj|j�|jjj	d|j�}|jt|jd�|j|j_	|jj�|jd�|j|jjj�d�|jj�|jdddi�|j|jjj�d�y	)
z.
        L{IRCGroup.sendGroupMessage}
        rGr�r�sPRIVMSG #foo :Some message 2
rvr�r�sPRIVMSG #foo :ACTION smiles
N)r:r>r;rm�getGroupr�r	�sendGroupMessager9r�r�rNr�r�)rr/s  r�test_sendGroupMessagez#IRCProtoTests.test_sendGroupMessage�s���	
�
�
�!�!�$�.�.�1��
�
���(�(�����<�����,��(>�(>��O�#�z�z��
�
��������
���/�0�����N�N���&�&�(�*M�	
�	
������
���x�'�7�);�<�����N�N���&�&�(�*T�	
r)�returnN)rrr�__doc__r<rArErIrQrZr^rcrgrtrxr�r�r�r�rrrr6r6.sW���+�	
�
�

�F�
9�C�4�	A�;�(;�(O�4I�
�*
rr6N)r��twisted.internet.testingr�twisted.words.im.basechatrrr�twisted.words.im.ircsupportrr�twisted.words.im.localsr	�twisted.words.test.test_ircr
rrr*r6rrr�<module>r�sS���5�M�M�<�0�3�!�|�!�!�-�!�K��K�b
�K�b
r

Zerion Mini Shell 1.0