HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/words/test/__pycache__/test_ircsupport.cpython-38.pyc
U


W[�)�@s�dZddlmZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
Gdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de
�ZdS)z+
Tests for L{twisted.words.im.ircsupport}.
�)�StringTransport)�ChatUI�Conversation�GroupConversation)�
IRCAccount�IRCProto)�OfflineError)�IRCTestCasec@seZdZdd�Zdd�ZdS)�StubConversationcCsdS�N���selfrr�D/usr/lib/python3/dist-packages/twisted/words/test/test_ircsupport.py�showszStubConversation.showcCs||_||_dSr)�message�metadata)rrrrrr�showMessageszStubConversation.showMessageN)�__name__�
__module__�__qualname__rrrrrrr
sr
c@s&eZdZdd�Zdd�Zddd�ZdS)	�StubGroupConversationcCs||_||_dSr)�topic�
topicSetBy)rrZnicknamerrr�setTopicszStubGroupConversation.setTopiccCsdSrrr
rrrr"szStubGroupConversation.showNcCs||_||_||_dSr)r�text)rZsenderrrrrr�showGroupMessage&sz&StubGroupConversation.showGroupMessage)N)rrrrrrrrrrrsrc@s(eZdZedfdd�Zedfdd�ZdS)�
StubChatUIrcCst�||||�Sr�r�getGroupConversation�r�groupZClassZ
stayHiddenrrr�getConversation.szStubChatUI.getConversationcCst�||||�Srrr rrrr2szStubChatUI.getGroupConversationN)rrrr
r"rrrrrrr-src@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�
IRCProtoTestsz 
    Tests for L{IRCProto}.
    cCs2tdddddd�|_t|jt�d�|_t�|_dS)NzSome accountF�alicezexample.comi)r�accountrr�protor�	transportr
rrr�setUp;s�zIRCProtoTests.setUpcCs$|j�|j�|�|j��d�dS)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�valuer
rrr�
test_loginBs
�zIRCProtoTests.test_logincCs,d|j_|j�|j�|�|j��d�dS)z�
        If created with an account with a password, L{IRCProto} sends a
        I{PASS} command before the I{NICK} and I{USER} commands.
        Zsecretz>PASS secret
NICK alice
USER alice foo bar :Twisted-IM user
N)r%Zpasswordr&r)r'r*r+r
rrr�test_authenticateNs�zIRCProtoTests.test_authenticatecCs0ddg|j_|j�|j�|�|j��d�dS)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)r%Zchannelsr&r)r'r*r+r
rrr�
test_channels\s�zIRCProtoTests.test_channelscCs4|j�|j�|j�d�|�d|jj�d��dS)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
�ZMODESN)r&r)r'�dataReceived�assertEqualZ	supportedZ
getFeaturer
rrr�
test_isupportks
�zIRCProtoTests.test_isupportcCsb|j�|j�|j�d�|j�d�|j�d�|j�d�|�d|jj�|�d|jj�dS)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
Znewnick�alice1N�r&r)r'r1�assertIn�	_ingroups�assertNotInr
rrr�	test_nickvszIRCProtoTests.test_nickcCs�|j�|j�|j�d�|�d|jjd�|�d|jjd�|j�d�|j�d�|j�d�|�d|jjd�|�d|jjd�dS)	zF
        IRC PART command removes a user from an IRC channel.
        r4�group1r5�group2z:alice PART #group1
z:alice1 PART #group1
z:alice1 PART #group2
Nr6r
rrr�	test_part�szIRCProtoTests.test_partcCs�|j�|j�|j�d�|�d|jjd�|�d|jjd�|j�d�|�d|jjd�|j�d�|�t|jjd�dk�|j�d	�d
S)zH
        IRC QUIT command removes a user from all IRC channels.
        r4r;r5r<z:alice1 JOIN #group3
Zgroup3z:alice1 QUIT
rz:alice3 QUIT
N)	r&r)r'r1r7r8r9Z
assertTrue�lenr
rrr�	test_quit�szIRCProtoTests.test_quitcCsR|j�|j�|j�d�|j�d�|j�d�}|�|jd�|�|jd�dS)zH
        IRC TOPIC command changes the topic of an IRC channel.
        r4z :alice1 TOPIC #group1 newtopic
r;Znewtopicr5N)r&r)r'r1rr2rr)r�groupConversationrrr�
test_topic�szIRCProtoTests.test_topiccCs�|j�|j�|j�d�|jj�|j�d��}|�|jd�|j�d�|j�	d�}|�|j
d�|j�d�|j�d�|j�	d	�}|�t
|d
��|jj�|j�d��}|�t
|d��dS)
zG
        PRIVMSG sends a private message to a user or channel.
        z#:alice1 PRIVMSG t2 test_message_1
r5Ztest_message_1z(:alice1 PRIVMSG #group1 test_message_2
r;Ztest_message_2r$z$:alice PRIVMSG #foo test_message_3
�foorrN�r&r)r'r1�chatr"�	getPersonr2rrrZsetNickZassertFalse�hasattr�rZconversationr@rrr�test_privmsg�s"
�
�zIRCProtoTests.test_privmsgcCs�|j�|j�|j�d�|jj�|j�d��}|�|jd�|j�d�|j�	d�}|�|j
d�|j�d�|j�d�|j�	d	�}|�t
|d
��|jj�|j�d��}|�t
|d��dS)
z3
        CTCP ACTION to a user or channel.
        z):alice1 PRIVMSG alice1 :ACTION smiles
r5�smilesz*:alice1 PRIVMSG #group1 :ACTION laughs
r;Zlaughsr$z(:alice PRIVMSG #group1 :ACTION cries
rBrrNrCrGrrr�test_action�s"
�
�zIRCProtoTests.test_actioncCs�|j�|j�|j�d�dgdgdgdgdgd�}ddddddgi}|�||jj�|�||jj�|j�d	�|�i|jj�|j�d�}|�|d|j�d
S)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
Zbnl)�Dan-�pSwede�SkOyg�MrOp�MrPlusrLrKrMrNrOz1:example.com 366 alice #bnl :End of /NAMES list
N)	r&r)r'r1r2r8Z_namrepliesr�members)rZexpectedInGroupsZexpectedNamRepliesr@rrr�test_rplNamreply�s*����zIRCProtoTests.test_rplNamreplycCs2|j�|j�|j�d�|�d|jjd�dS)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 topicrBN)r&r)r'r1r2Z_topicsr
rrr�
test_rplTopic�s
�zIRCProtoTests.test_rplTopiccCs�|j�|j�|j�d�}|�t|jd�|j|j_|j�	�|�d�|�
|jj��d�|j�	�|�dddi�|�
|jj��d�d	S)
z*
        L{IRCPerson.sendMessage}
        r$�Some message�Some message 2sPRIVMSG alice :Some message 2
rI�style�emotes PRIVMSG alice :ACTION smiles
N)
r&r)r'rE�assertRaisesrZsendMessager%�client�clearr2�io�getvalue)rZpersonrrr�test_sendMessage�s


�
�zIRCProtoTests.test_sendMessagecCs�|j�|j�|jj�d|j�}|�t|jd�|j|j_	|j�
�|�d�|�|jj�
�d�|j�
�|�dddi�|�|jj�
�d�d	S)
z.
        L{IRCGroup.sendGroupMessage}
        r.rSrTsPRIVMSG #foo :Some message 2
rIrUrVsPRIVMSG #foo :ACTION smiles
N)r&r)r'rDZgetGrouprWrZsendGroupMessager%rXrYr2rZr[)rr!rrr�test_sendGroupMessages


�
�z#IRCProtoTests.test_sendGroupMessageN)rrr�__doc__r(r,r-r/r3r:r=r?rArHrJrQrRr\r]rrrrr#7s 

r#N)r^Ztwisted.test.proto_helpersrZtwisted.words.im.basechatrrrZtwisted.words.im.ircsupportrrZtwisted.words.im.localsrZtwisted.words.test.test_ircr	r
rrr#rrrr�<module>s