+
    Dfj)                         R t ^ RIHt ^ RIHtHtHt ^ RIHtH	t	 ^ RI
Ht ^ RIHt  ! R R]4      t ! R R	]4      t ! R
 R]4      t ! R R]4      tR# )z+
Tests for L{twisted.words.im.ircsupport}.
)StringTransport)ChatUIConversationGroupConversation)
IRCAccountIRCProto)OfflineError)IRCTestCasec                   ,   a  ] tR t^t o R tR tRtV tR# )StubConversationc                    R # N selfs   &D/usr/lib/python3/dist-packages/twisted/words/test/test_ircsupport.pyshowStubConversation.show           c                    Wn         W n        R # r   messagemetadata)r   r   r   s   &&&r   showMessageStubConversation.showMessage   s     r   r   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     ! !r   r   c                   6   a  ] tR t^t o R tR tRR ltRtV tR# )StubGroupConversationc                    Wn         W n        R # r   )topic
topicSetBy)r   r'   nicknames   &&&r   setTopicStubGroupConversation.setTopic   s    
"r   c                    R # r   r   r   s   &r   r   StubGroupConversation.show   r   r   Nc                *    W0n         W n        W0n         R # r   )r   text)r   senderr/   r   s   &&&&r   showGroupMessage&StubGroupConversation.showGroupMessage    s     	 r   )r   r/   r'   r(   r   )	r   r   r   r   r*   r   r1   r    r!   r"   s   @r   r%   r%      s     #! !r   r%   c                   <   a  ] tR t^&t o ]^ 3R lt]^ 3R ltRtV t	R# )
StubChatUIc                0    \         P                  ! WW#4      # r   r   getGroupConversationr   groupClass
stayHiddens   &&&&r   getConversationStubChatUI.getConversation'       **4JJr   c                0    \         P                  ! WW#4      # r   r6   r8   s   &&&&r   r7   StubChatUI.getGroupConversation*   r>   r   r   N)
r   r   r   r   r   r<   r%   r7   r    r!   r"   s   @r   r4   r4   &   s%     +; K 1FRS K Kr   r4   c                   2  a  ] tR t^.t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltR tV tR!# )"IRCProtoTestsz
Tests for L{IRCProto}.
c                   < V ^8  d   QhRR/#    returnNr   )formatr#   s   "r   __annotate__IRCProtoTests.__annotate__3   s     + +t +r   c                    \        R RRRRR4      V n        \        V P                  \        4       R4      V n        \        4       V n        R# )zSome accountFaliceNzexample.comi  )r   accountr   r4   protor   	transportr   s   &r   setUpIRCProtoTests.setUp3   s=    !E7D-
 dllJL$?
(*r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   :   s     	
 	
D 	
r   c                    V P                   P                  V P                  4       V P                  V P                  P	                  4       R4       R# )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)rM   makeConnectionrN   assertEqualBufferValuevaluer   s   &r   
test_loginIRCProtoTests.test_login:   s;    
 	

!!$..1##NN  "F	
r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   E   s     
 
4 
r   c                    RV P                   n        V P                  P                  V P                  4       V P                  V P                  P                  4       R4       R# )zz
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)rL   passwordrM   rS   rN   rT   rU   r   s   &r   test_authenticateIRCProtoTests.test_authenticateE   sI    
 !)

!!$..1##NN  "6	
r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   S   s     
 
t 
r   c                    RR.V P                   n        V P                  P                  V P                  4       V P                  V P                  P                  4       R4       R# )zq
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)rL   channelsrM   rS   rN   rT   rU   r   s   &r   test_channelsIRCProtoTests.test_channelsS   sN    
 "( 0

!!$..1##NN  "	
r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   b   s     F Ft Fr   c                    V P                   P                  V P                  4       V P                   P                  R4       V P	                  ^V P                   P
                  P                  R4      4       R# )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)rM   rS   rN   dataReceivedassertEqual	supported
getFeaturer   s   &r   test_isupportIRCProtoTests.test_isupportb   sR    
 	

!!$..1

 WXDJJ00;;GDEr   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   k   s     
9 
94 
9r   c                   V P                   P                  V P                  4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P	                  RV P                   P
                  4       V P                  RV P                   P
                  4       R# )z2
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rM   rS   rN   rg   assertIn	_ingroupsassertNotInr   s   &r   	test_nickIRCProtoTests.test_nickk   s     	

!!$..1

 9:

 :;

 :;

 ;<i!5!564::#7#78r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI   w   s     C C4 Cr   c                   V P                   P                  V P                  4       V P                   P                  R4       V P	                  RV P                   P
                  R,          4       V P                  RV P                   P
                  R,          4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                  RV P                   P
                  R,          4       V P                  RV P                   P
                  R,          4       R# )	z6
IRC PART command removes a user from an IRC channel.
ro   group1rq   group2z:alice PART #group1
z:alice1 PART #group1
z:alice1 PART #group2
Nrr   r   s   &r   	test_partIRCProtoTests.test_partw   s     	

!!$..1

 :;h

 4 4X >?4::#7#7#AB

 9:

 :;

 :;4::#7#7#AB4::#7#7#ABr   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     4 44 4r   c                   V P                   P                  V P                  4       V P                   P                  R4       V P	                  RV P                   P
                  R,          4       V P                  RV P                   P
                  R,          4       V P                   P                  R4       V P	                  RV P                   P
                  R,          4       V P                   P                  R4       V P                  \        V P                   P
                  R,          4      ^ 8H  4       V P                   P                  R4       R	# )
z8
IRC QUIT command removes a user from all IRC channels.
ro   rz   rq   r{   z:alice1 JOIN #group3
group3z:alice1 QUIT
z:alice3 QUIT
N)	rM   rS   rN   rg   rs   rt   ru   
assertTruelenr   s   &r   	test_quitIRCProtoTests.test_quit   s     	

!!$..1

 :;h

 4 4X >?4::#7#7#AB

 :;h

 4 4X >?

 23DJJ00:;q@A

 23r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     	A 	AD 	Ar   c                b   V P                   P                  V P                  4       V P                   P                  R4       V P                   P                  R4       V P                   P	                  R4      pV P                  VP                  R4       V P                  VP                  R4       R# )z8
IRC TOPIC command changes the topic of an IRC channel.
ro   z :alice1 TOPIC #group1 newtopic
rz   newtopicrq   N)rM   rS   rN   rg   r7   rh   r'   r(   )r   groupConversations   & r   
test_topicIRCProtoTests.test_topic   s     	

!!$..1

 :;

 DE JJ;;HE*00*=*55x@r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     ; ;d ;r   c                h   V P                   P                  V P                  4       V P                   P                  R4       V P                   P                  P                  V P                   P                  R4      4      pV P                  VP                  R4       V P                   P                  R4       V P                   P                  R4      pV P                  VP                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R	4      pV P                  \        VR
4      4       V P                   P                  P                  V P                   P                  R4      4      pV P                  \        VR4      4       R# )z7
PRIVMSG sends a private message to a user or channel.
z#:alice1 PRIVMSG t2 test_message_1
rq   test_message_1z(:alice1 PRIVMSG #group1 test_message_2
rz   test_message_2rK   z$:alice PRIVMSG #foo test_message_3
foor/   r   NrM   rS   rN   rg   chatr<   	getPersonrh   r   r7   r/   setNickassertFalsehasattrr   conversationr   s   &  r   test_privmsgIRCProtoTests.test_privmsg   s7    	

!!$..1

 GHzz66tzz7K7KH7UV--/?@

 LM JJ;;HE*//1AB

7#

 HI JJ;;EB!2F;<zz66tzz7K7KG7TUy9:r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     ; ;T ;r   c                h   V P                   P                  V P                  4       V P                   P                  R4       V P                   P                  P                  V P                   P                  R4      4      pV P                  VP                  R4       V P                   P                  R4       V P                   P                  R4      pV P                  VP                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R	4      pV P                  \        VR
4      4       V P                   P                  P                  V P                   P                  R4      4      pV P                  \        VR4      4       R# )z#
CTCP ACTION to a user or channel.
z):alice1 PRIVMSG alice1 :ACTION smiles
rq   smilesz*:alice1 PRIVMSG #group1 :ACTION laughs
rz   laughsrK   z(:alice PRIVMSG #group1 :ACTION cries
r   r/   r   Nr   r   s   &  r   test_actionIRCProtoTests.test_action   s5    	

!!$..1

 QRzz66tzz7K7KH7UV--x8

 RS JJ;;HE*//:

7#

 PQ JJ;;EB!2F;<zz66tzz7K7KG7TUy9:r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     O O$ Or   c           
     F   V P                   P                  V P                  4       V P                   P                  R4       RR.RR.RR.RR.RR./pR. R
O/pV P	                  WP                   P
                  4       V P	                  W P                   P                  4       V P                   P                  R4       V P	                  / V P                   P                  4       V P                   P                  R4      pV P	                  VR,          VP                  4       R	# )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
Dan-bnlpSwedeSkOygMrOpMrPlusz1:example.com 366 alice #bnl :End of /NAMES list
N)r   r   r   r   r   )	rM   rS   rN   rg   rh   rt   _namrepliesr7   members)r   expectedInGroupsexpectedNamRepliesr   s   &   r   test_rplNamreplyIRCProtoTests.test_rplNamreply   s     	

!!$..1

N	
 UGugeWUGug
 $%RS)::+?+?@+ZZ-C-CD

 UVTZZ334 JJ;;EB+E24E4M4MNr   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     I It Ir   c                    V P                   P                  V P                  4       V P                   P                  R4       V P	                  RV P                   P
                  R,          4       R# )zK
RPL_TOPIC server response (332) is sent when a channel's topic is changed
z1:example.com 332 alice, #foo :Some random topic
zSome random topicr   N)rM   rS   rN   rg   rh   _topicsr   s   &r   test_rplTopicIRCProtoTests.test_rplTopic   sM     	

!!$..1

 UV,djj.@.@.GHr   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     
 
$ 
r   c                   V P                   P                  V P                  4       V P                   P                  R4      pV P	                  \
        VP                  R4       V P                   VP                  n        V P                  P                  4        VP                  R4       V P                  V P                  P                  P                  4       R4       V P                  P                  4        VP                  RRR/4       V P                  V P                  P                  P                  4       R4       R	# )
z
L{IRCPerson.sendMessage}
rK   Some messageSome message 2s   PRIVMSG alice :Some message 2
r   styleemotes    PRIVMSG alice :ACTION smiles
N)rM   rS   rN   r   assertRaisesr   sendMessagerL   clientclearrh   iogetvalue)r   persons   & r   test_sendMessageIRCProtoTests.test_sendMessage   s     	

!!$..1%%g.,(:(:NK $

+,NN&&(*N	
 	8gw%78NN&&(*U	
r   c                   < V ^8  d   QhRR/# rD   r   )rG   r#   s   "r   rH   rI      s     
 
t 
r   c                   V P                   P                  V P                  4       V P                   P                  P	                  RV P                   4      pV P                  \        VP                  R4       V P                   VP                  n	        V P                  P                  4        VP                  R4       V P                  V P                  P                  P                  4       R4       V P                  P                  4        VP                  RRR/4       V P                  V P                  P                  P                  4       R4       R	# )
z
L{IRCGroup.sendGroupMessage}
r`   r   r   s   PRIVMSG #foo :Some message 2
r   r   r   s   PRIVMSG #foo :ACTION smiles
N)rM   rS   rN   r   getGroupr   r   sendGroupMessagerL   r   r   rh   r   r   )r   r9   s   & r   test_sendGroupMessage#IRCProtoTests.test_sendGroupMessage   s     	

!!$..1

((<,(>(>O#zz/0NN&&(*M	
 	x'7);<NN&&(*T	
r   )rL   rM   rN   N)r   r   r   r   __doc__rO   rV   r\   rb   rk   rv   r|   r   r   r   r   r   r   r   r   r    r!   r"   s   @r   rB   rB   .   s     + +	
 	

 

 
F F
9 
9C C4 4	A 	A; ;(; ;(O O4I I
 
*
 
r   rB   N)r   twisted.internet.testingr   twisted.words.im.basechatr   r   r   twisted.words.im.ircsupportr   r   twisted.words.im.localsr   twisted.words.test.test_ircr	   r   r%   r4   rB   r   r   r   <module>r      sS    5 M M < 0 3!| !!- !K Kb
K b
r   