+
    Dfj̜                       R t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHt  ! R R	]4      t ! R
 R]4      t ! R R]4      t ! R R]4      t ! R R]4      tRRP3                  ]P4                  R7      RP3                  ]P6                  ]P8                  R7      RR]P:                  R]P<                  /,          .t ! R R]4      t  ! R R]PB                  4      t" ! R R]4      t# ! R  R!]4      t$ ! R" R#]P"                  4      t% ! R$ R%]4      t& ! R& R']%4      t'R( t( ! R) R*]4      t) ! R+ R,]4      t* ! R- R.]P"                  4      t+ ! R/ R0]4      t, ! R1 R2]4      t- ! R3 R4]4      t. ! R5 R6]P"                  4      t/ ! R7 R8]4      t0 ! R9 R:]4      t1 ! R; R<]4      t2 ! R= R>]4      t3 ! R? R@]4      t4 ! RA RB]4      t5R# )Cz+
Tests for L{twisted.words.protocols.irc}.
N)protocoltask)StringIOWithoutClosingStringTransport)FilePath)TestCase)irc)	IRCClient
attributesc                   &   a  ] tR t^t o R tRtV tR# )IRCTestCasec                (   Tp\        V\        4      '       d   VP                  R4      p\        V\        4      '       d=   \        V^ ,          \        4      '       d    V Uu. uF  qDP                  R4      NK  	  ppV P	                  W24       R# u upi )z
A buffer is always bytes, but sometimes
we need to compare it to a utf-8 unicode string

@param buf: the buffer
@type buf: L{bytes} or L{unicode} or L{list}
@param val: the value to compare
@type val: L{bytes} or L{unicode} or L{list}
utf-8utf8N)
isinstancestrdecodelistassertEqual)selfbufvalbufferValuebs   &&&  =/usr/lib/python3/dist-packages/twisted/words/test/test_irc.pyassertEqualBufferValue"IRCTestCase.assertEqualBufferValue   ss     c3%,,W5Kk4((#a&#&&9DEAxx/E* Fs   !B N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     + +    r   c                   d   a  ] tR t^)t o RtRtR tR tR tR t	R t
R tR tR	 tR
 tR tRtV tR# )ModeParsingTestsz6
Tests for L{twisted.words.protocols.irc.parseModes}.
c                f    V P                  \        P                  \        P                  R. 4       R# )z9
Parsing an empty mode string raises L{irc.IRCBadModes}.
 NassertRaisesr   IRCBadModes
parseModesr   s   &r   test_emptyModes ModeParsingTests.test_emptyModes0   s      	#//3>>2rBr&   c                   V P                  \        P                  \        P                  R. 4       V P                  \        P                  \        P                  R. 4       V P                  \        P                  \        P                  R. 4       V P                  \        P                  \        P                  R. 4       R# )z
Parsing a mode string that contains an empty sequence (either a C{+} or
C{-} followed directly by another C{+} or C{-}, or not followed by
anything at all) raises L{irc.IRCBadModes}.
z++kz-+k+-Nr+   r/   s   &r   test_emptyModeSequence'ModeParsingTests.test_emptyModeSequence6   st     	#//3>>5"E#//3>>5"E#//3>>3C#//3>>3Cr&   c                    V P                  \        P                  \        P                  R. 4       V P                  \        P                  \        P                  R. 4       R# )zX
Parsing a mode string that does not start with C{+} or C{-} raises
L{irc.IRCBadModes}.
foo%Nr+   r/   s   &r   test_malformedModes$ModeParsingTests.test_malformedModesA   s<    
 	#//3>>5"E#//3>>3Cr&   c                    V P                  \        P                  \        P                  R. 4       V P                  \        P                  \        P                  R. 4       R# )zS
Parsing a mode string that contains no mode characters raises
L{irc.IRCBadModes}.
r3   r4   Nr+   r/   s   &r   test_nullModesModeParsingTests.test_nullModesI   s<    
 	#//3>>3C#//3>>3Cr&   c                    \         P                  ! R. 4      w  rV P                  VR.4       V P                  V. 4       \         P                  ! R. 4      w  rV P                  V. 4       V P                  VR.4       R# )z
Parsing a single mode setting with no parameters results in that mode,
with no parameters, in the "added" direction and no modes in the
"removed" direction.
+sN-ssNr   r.   r   r   addedremoveds   &  r   test_singleMode ModeParsingTests.test_singleModeQ   sl     b1."%b1#;-0r&   c                   \         P                  ! R. 4      w  rV P                  V. RO4       V P                  V. 4       \         P                  ! R. 4      w  rV P                  V. 4       V P                  VRR.4       R# )z
Parsing a single-direction mode setting with multiple modes and no
parameters, results in all modes falling into the same direction group.
z+stnNz-nttNnN)rB   rK   rM   rD   rE   s   &  r   test_singleDirection%ModeParsingTests.test_singleDirection_   sn    
 3 GH"%r2#;"<=r&   c                    \         P                  ! R. 4      w  rV P                  V. RO4       V P                  VR.4       R# )z<
Parsing a multi-direction mode setting with no parameters.
z+s-n+tiN)rB   rK   iNrM   rD   rE   s   &  r   test_multiDirection$ModeParsingTests.test_multiDirectionl   s9     	26 GH;-0r&   c                    \         P                  ! R. 4      w  rV P                  V. RO4       V P                  V. 4       R# )z
Parsing a multi-direction mode setting containing two consecutive mode
sequences with the same direction results in the same result as if
there were only one mode sequence in the same direction.
z+sn+tiN)rB   rM   rK   rR   rD   rE   s   &  r   test_consecutiveDirection*ModeParsingTests.test_consecutiveDirectiont   s7     "5 TU"%r&   c                    V P                  \        P                  \        P                  R. V P                  4       V P                  \        P                  \        P                  R. ROV P                  4       R# )zy
If the number of mode parameters does not match the number of modes
expecting parameters, L{irc.IRCBadModes} is raised.
z+kz+klN)r8   10lulz_extra_param)r,   r   r-   r.   
paramModesr/   s   &r   test_mismatchedParams&ModeParsingTests.test_mismatchedParams~   sO    
 	#//3>>4T__UOONN-OO	
r&   c                   \         P                  ! R. ROV P                  4      w  rV P                  V. RO4       V P                  V. 4       \         P                  ! RRR.V P                  4      w  rV P                  V. 4       V P                  V. R	O4       \         P                  ! R. R
OV P                  4      w  rV P                  V. RO4       V P                  V. 4       R# )z
Modes which require parameters are parsed and paired with their relevant
parameter, modes which do not require parameters do not consume any of
the parameters.
z+klbbnick!user@host	other!*@*z-klbbNz+knbb)somekey42r`   ra   )krb   )lrc   r   r`   r   ra   ))re   N)rf   Nrg   rh   )rb   r`   ra   )rd   rM   rg   rh   )r   r.   r\   r   rE   s   &  r   test_parameters ModeParsingTests.test_parameters   s     Et
 		
 	"%&4doo
 	#S	
 ?
 		
 	"%r&   r   N)klbr   )r   r   r    r!   __doc__r\   r0   r5   r:   r=   rH   rO   rT   rW   r]   ri   r"   r#   r$   s   @r   r(   r(   )   sL      JC	DDD1>1&
*& *&r&   r(   c                   *   a  ] tR t^t o RtR tRtV tR# )	MiscTestsz$
Tests for miscellaneous functions.
c           
         V P                  \        P                  ! \        P                  ^ . RO4      R4       R pV P                  \        P                  ! V. ^.^.^.^..4      . ^.^.^.^.4       R# )z
Apply a function of two arguments cumulatively to the items of
a sequence, from right to left, so as to reduce the sequence to
a single value.
c                 *    V P                  ^ V4       V # )    )insert)rf   xs   &&r   	insertTop'MiscTests.test_foldr.<locals>.insertTop   s    HHQNHr&   N)            )r   r   _foldroperatorsub)r   rt   s   & r   
test_foldrMiscTests.test_foldr   sp     	HLL!\BBG	 	JJy"sQC!qc&:;Q|Q>OQR=S	
r&   r   N)r   r   r    r!   rl   r~   r"   r#   r$   s   @r   rn   rn      s     
 
r&   rn   c                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tRtV tR# )FormattedTextTestsz6
Tests for parsing and assembling formatted IRC text.
c                T    \         P                  ! V4      pV P                  W24       R# )a  
Assert that C{text} is parsed and assembled to the same value as what
C{expectedFormatted} is assembled to. This provides a way to ignore
meaningless differences in the formatting structure that would be
difficult to detect without rendering the structures.
N)r   parseFormattedTextassertAssemblesTo)r   textexpectedFormatted	formatteds   &&& r   assertAssembledEqually)FormattedTextTests.assertAssembledEqually   s"     **40	y<r&   c                    \         P                  ! V4      p\         P                  ! V4      pV P                  \         P                  ! V4      VV: RV: RV: RV: R24       R# )zO
Assert that C{formatted} and C{expectedFormatted} assemble to the same
value.
z (z) is not equivalent to )N)r   assembleFormattedTextr   )r   r   r   r   expectedTexts   &&&  r   r   $FormattedTextTests.assertAssemblesTo   sT    
 ((3001BC%%i0Y.?A	
r&   c                F    V P                  R\        P                  4       R# )z?
An empty string parses to a I{normal} attribute with no text.
r*   N)r   Anormalr/   s   &r   test_parseEmpty"FormattedTextTests.test_parseEmpty   s     	##B1r&   c                    V P                  \        P                  ! \        P                  4      R4       V P                  \        P                  ! \        P
                  R,          4      R4       R# )z
An attribute with no text assembles to the empty string. An attribute
whose text is the empty string assembles to two control codes: C{off}
and that of the attribute.
r*   zN)r   r   r   r   r   boldr/   s   &r   test_assembleEmpty%FormattedTextTests.test_assembleEmpty   sH     	22188<bA 	22166":>
Kr&   c                |    V P                  \        P                  ! \        P                  R,          4      R4       R# )zQ
A I{normal} string assembles to a string prefixed with the I{off}
control code.
hellozhelloN)r   r   r   r   r   r/   s   &r   test_assembleNormal&FormattedTextTests.test_assembleNormal   s(    
 	22188G3DE{Sr&   c                |    V P                  \        P                  ! \        P                  R,          4      R4       R# )z\
A I{bold} string assembles to a string prefixed with the I{off} and
I{bold} control codes.
r   zhelloN)r   r   r   r   r   r/   s   &r   test_assembleBold$FormattedTextTests.test_assembleBold  s'    
 	22166'?C_Ur&   c                |    V P                  \        P                  ! \        P                  R,          4      R4       R# )zg
An I{underline} string assembles to a string prefixed with the I{off}
and I{underline} control codes.
r   zhelloN)r   r   r   r   	underliner/   s   &r   test_assembleUnderline)FormattedTextTests.test_assembleUnderline  s+    
 	%%akk'&:;_	
r&   c                |    V P                  \        P                  ! \        P                  R,          4      R4       R# )zn
A I{reverse video} string assembles to a string prefixed with the I{off}
and I{reverse video} control codes.
r   zhelloN)r   r   r   r   reverseVideor/   s   &r   test_assembleReverseVideo,FormattedTextTests.test_assembleReverseVideo  s+    
 	%%annW&=>	
r&   c                    V P                  \        P                  ! \        P                  P
                  R,          4      R4       R# )z
A I{foreground color} string assembles to a string prefixed with the
I{off} and I{color} (followed by the relevant foreground color code)
control codes.
r   z	02helloN)r   r   r   r   fgbluer/   s   &r   test_assembleForegroundColor/FormattedTextTests.test_assembleForegroundColor  s0     	%%addii&89;L	
r&   c                    V P                  \        P                  ! \        P                  P
                  R,          4      R4       R# )z
A I{background color} string assembles to a string prefixed with the
I{off} and I{color} (followed by a I{,} to indicate the absence of a
foreground color, followed by the relevant background color code)
control codes.
r   z
,02helloN)r   r   r   r   bgr   r/   s   &r   test_assembleBackgroundColor/FormattedTextTests.test_assembleBackgroundColor(  s0     	%%addii&89;M	
r&   c                    V P                  \        P                  ! \        P                  P
                  \        P                  P                  R,          ,          4      R4       R# )z
A I{foreground} and I{background} color string assembles to a string
prefixed with the I{off} and I{color} (followed by the relevant
foreground color, I{,} and the relevant background color code) control
codes.
r   z05,02helloN)r   r   r   r   r   redr   r   r/   s   &r   test_assembleColor%FormattedTextTests.test_assembleColor3  s=     	%%addhhqttyy/A&BC 	
r&   c                   V P                  \        P                  ! \        P                  R\        P
                  R,          3,          4      R4       V P                  \        P                  ! \        P                  \        P                  P                  \        P                  P                  R,          R3,          \        P                  R,          3,          4      R4       R# )z;
Nested attributes retain the attributes of their parents.
r    worldzhello worldz yayz05,03hello05 world yayN)r   r   r   r   r   r   r   r   r   r   greenr   r/   s   &r   test_assembleNested&FormattedTextTests.test_assembleNested?  s     	%%affWakk(6K-K&LM-	

 	%%DDHHQTTZZ0(:;Q^^F=SS
 =	
r&   c                |    V P                  \        P                  ! R4      \        P                  R,          4       R# )zS
Parsing unformatted text results in text with attributes that
constitute a no-op.
r   N)r   r   r   r   r   r/   s   &r   test_parseUnformattedText,FormattedTextTests.test_parseUnformattedTextQ  s(    
 	//8!((7:KLr&   c                $   V P                  \        P                  ! R4      \        P                  P
                  R,          4       V P                  \        P                  ! R4      \        P                  P
                  \        P                  P                  R,          ,          4       V P                  \        P                  ! R4      \        P                  P
                  R\        P                  P                  R,          3,          4       R# )zg
Correctly formatted text with colors uses 2 digits to specify
foreground and (optionally) background.
z01yayyayz
01,02yayz01yay02yipeeyipeeN)r   r   r   r   r   blackr   r   r/   s   &r   test_colorFormatting'FormattedTextTests.test_colorFormattingX  s    
 	//@!$$**UBST""#56

14499UCS8T	
 	""#=>DDJJuaddii001	
r&   c                   V P                  R\        P                  P                  R,          4       V P                  R\        P                  P                  R,          4       V P                  R\        P                  P                  \        P
                  P                  R,          ,          4       V P                  R\        P                  P                  \        P
                  P                  R,          ,          4       V P                  R\        P                  P                  \        P
                  P                  R	,          ,          4       V P                  R
\        P                  R,          4       V P                  R\        P                  R,          4       V P                  R\        P                  P                  R,          4       V P                  R\        P                  4       R# )ab  
Formatted text with colors can use 1 digit for both foreground and
background, as long as the text part does not begin with a digit.
Foreground and background colors are only processed to a maximum of 2
digits per component, anything else is treated as text. Color sequences
must begin with a digit, otherwise processing falls back to unformatted
text.
z1kinda validzkinda validz999,999kinda validz9,999kinda validz1,2kinda validz1,999kinda validz9kinda validz1,242 is a special numberz2 is a special numberz	,02oopsz,02oopszwrongwrongz1,hellor   zN)	r   r   r   r   r   r   r   yellowr   r/   s   &r   test_weirdColorFormatting,FormattedTextTests.test_weirdColorFormattingf  s8    	##$6

=8QR##$addjj1C&D	
 	## !$$**QTTYY}-E"F	
 	##"ADDJJqttzz./I$J	
 	##+DDJJqtt{{#:;<	
 	##$5qxx	7JK##K'1BC##M144::g3FG##J9r&   c                d   V P                  R\        P                  \        P                  P                  R,          R3,          4       V P                  R\        P                  \        P                  P                  \        P
                  P                  R,          ,          R3,          4       R# )zJ
An empty color format specifier clears foreground and background
colors.
z01yayresetr   resetz01,02yayresetN)r   r   r   r   r   r   r   r/   s   &r   test_clearColorFormatting,FormattedTextTests.test_clearColorFormatting  so    
 	## !((144::e+<g+E"F	
 	###QXXaddjj59I.JG.S%T	
r&   c                
   V P                  R\        P                  \        P                  \        P                  R,          ,          R3,          4       V P                  R\        P                  \        P
                  P                  R,          R3,          4       V P                  R\        P                  \        P
                  P                  \        P                  P                  R,          ,          R3,          4       R# )z<
A reset format specifier clears all formatting attributes.
zyayresetr   r   z01yayresetz01,02yayresetN)	r   r   r   r   r   r   r   r   r   r/   s   &r   test_resetFormatting'FormattedTextTests.test_resetFormatting  s     	##"AHHQVVAKK4F-G-P$Q	
 	## !((144::e+<g+E"F	
 	###QXXaddjj59I.JG.S%T	
r&   c                x   V P                  \        P                  ! \        P                  ! \        P
                  \        P                  \        P                  \        P                  P                  \        P                  P                  R,          ,          ,          R3,          ,          4      4      R4       R# )zJ
Strip formatting codes from formatted text, leaving only the text parts.
r   r   zhello worldN)r   r   stripFormattingr   r   r   r   r   r   r   r   r   r/   s   &r   test_stripFormatting'FormattedTextTests.test_stripFormatting  sv     	))FFNN14488ADDJJw4G+HI8S 	
r&   r   N)r   r   r    r!   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r#   r$   s   @r   r   r      sm     =
2
LTV


	



$M
:8



 
r&   r   c                   *   a  ] tR tRt o RtR tRtV tR# )FormattingStateAttributeTestsi  z<
Tests for L{twisted.words.protocols.irc._FormattingState}.
c                >   V P                  \        P                  ! 4       \        P                  ! 4       4       V P                  \        P                  ! 4       \        P                  ! RR7      4       V P                  \        P                  ! RRRR\        P                  R,          R7      \        P                  ! RRRR\        P                  R,          R7      4       V P	                  \        P                  ! RR7      \        P                  ! RR7      4       R# )z
L{irc._FormattingState}s must have matching character attribute
values (bold, underline, etc) with the same values to be considered
equal.
F)offTr   )r   r   r   r   
foreground)r   N)r   r   _FormattingState_IRC_COLORSassertNotEqualr/   s   &r   test_equality+FormattingStateAttributeTests.test_equality  s     	--/1E1E1GH--/1E1E%1PQ  !??62   !??62	
" 	  d+S-A-Au-M	
r&   r   N)r   r   r    r!   rl   r   r"   r#   r$   s   @r   r   r     s     
 
r&   r   z3Hello, this is a nice string with no complications.z!xargs{NUL}might{NUL}like{NUL}this)NULz"embedded{CR}newline{CR}{NL}FUN{NL})CRNLz,escape!%(X)s escape!%(M)s %(X)s%(X)sa %(M)s0XMc                   ,   a  ] tR tRt o R tR tRtV tR# )QuotingTestsi  c           	         \          F=  pV P                  V\        P                  ! \        P                  ! V4      4      4       K?  	  R# )z,
Testing client-server level quote/dequote.
N)stringSubjectsr   r   
lowDequotelowQuoter   rC   s   & r   test_lowquoteSanity QuotingTests.test_lowquoteSanity  s/      AQs||A ?@  r&   c           	         \          F=  pV P                  V\        P                  ! \        P                  ! V4      4      4       K?  	  R# )z+
Testing CTCP message level quote/dequote.
N)r   r   r   ctcpDequote	ctcpQuoter   s   & r   test_ctcpquoteSanity!QuotingTests.test_ctcpquoteSanity  s0      AQa0@ AB  r&   r   N)r   r   r    r!   r   r   r"   r#   r$   s   @r   r   r     s     AC Cr&   r   c                   4   a  ] tR tRt o RtRtR tR tRtV t	R# )
Dispatcheri  zK
A dispatcher that exposes one known command and handles unknown commands.
dispc                    W3# )z)
A known command that returns its input.
r   )r   ar   s   &&&r   disp_workingDispatcher.disp_working  s     tr&   c                
    WV3# )z=
Handle unknown commands by returning their name and inputs.
r   )r   namer   r   s   &&&&r   disp_unknownDispatcher.disp_unknown  s     zr&   r   N)
r   r   r    r!   rl   prefixr   r   r"   r#   r$   s   @r   r   r     s       F r&   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )DispatcherTestsi   z+
Tests for L{irc._CommandDispatcherMixin}.
c                h    \        4       pRpVP                  ! R.VO5!  pV P                  W24       R# )z4
Dispatching a command invokes the correct handler.
workingNrv   rw   r   dispatchr   )r   r   argsress   &   r   test_dispatchDispatcherTests.test_dispatch  s1     |mmI--#r&   c                |    \        4       pRpRpVP                  ! V.VO5!  pV P                  WB3V,           4       R# )z=
Dispatching an unknown command invokes the default handler.
missingNr   r   )r   r   r   r  r  s   &    r   test_dispatchUnknown$DispatcherTests.test_dispatchUnknown  s<     |mmD(4(gn-r&   c                ~    \        4       pRVn        V P                  \        P                  VP
                  R4       R# )zk
Dispatching an unknown command, when no default handler is present,
results in an exception being raised.
Nbar)r   r   r,   r   UnhandledCommandr  )r   r   s   & r   test_dispatchMissingUnknown+DispatcherTests.test_dispatchMissingUnknown  s/    
 | #..uEr&   r   N)
r   r   r    r!   rl   r  r  r  r"   r#   r$   s   @r   r   r      s      $.F Fr&   r   c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR R ltR R ltR R ltR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRt V t!R# )!ServerSupportedFeatureTestsi"  z=
Tests for L{ServerSupportedFeatures} and related functions.
c                   V P                  \        P                  ! R4      R4       V P                  \        P                  ! . 4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R^4      ^4       V P                  \        P                  ! R4      ^{4       V P                  \        P                  ! ^{4      ^{4       R# )z\
L{_intOrDefault} converts values to C{int} if possible, otherwise
returns a default value.
Nr*   r   123)r   r   _intOrDefaultr/   s   &r   test_intOrDefault-ServerSupportedFeatureTests.test_intOrDefault'  s    
 	**40$7**2.5**2.5**7A6:**5137**3/5r&   c           
        RRR.33RRR.33RRR.33RR. RO33RRR.33R	RR
.33RRR.33RRR.33.p\         P                  P                  pV F  w  r4V! V4      pV P                  WT4       K   	  V P	                  \
        VR4       V P	                  \
        VR4       V P	                  \
        VR4       V P	                  \
        VR4       R# )z
L{ServerSupportedFeatures._splitParam} splits ISUPPORT parameters
into key and values. Parameters without a separator are split into a
key and a list containing only the empty string. Escaped parameters
are unescaped.
FOOr*   zFOO=zFOO=11z	FOO=1,2,3z
FOO=A\x20BzA Bz	FOO=\x5Cxz\xzFOO=\\zFOO=\nz\nzFOO=\xzFOO=\xNNzFOO=\xNz
FOO=\x20\xN)r  23)r   ServerSupportedFeatures_splitParamr   r,   
ValueError)r   paramsr  paramexpectedr  s   &     r   test_splitParam+ServerSupportedFeatureTests.test_splitParam3  s     URDM"ebT]#usen%5/23UUG,-EE7+,v'()	
 11==%OEe$CS+  & 	*k9=*k;?*k:>*k>Br&   c                p    \         P                  P                  . RO4      pV P                  V. RO4       R# )z
L{ServerSupportedFeatures._splitParamArgs} splits ISUPPORT parameter
arguments into key and value.  Arguments without a separator are
split into a key and an empty string.
N)A:1B:2zC:D))r   r  )Br  )Cr*   )r'  r*   )r   r  _splitParamArgsr   r   r  s   & r   test_splitParamArgs/ServerSupportedFeatureTests.test_splitParamArgsP  s,     ))99:STLMr&   c                    \         P                  P                  . RO\         P                  4      pV P	                  V. RO4       R# )z
L{ServerSupportedFeatures._splitParamArgs} uses the argument processor
passed to convert ISUPPORT argument values to some more suitable
form.
N)r%  r&  r)  ))r   rv   )r(  rw   )r)  N)r   r  r*  r  r   r+  s   & r   test_splitParamArgsProcessor8ServerSupportedFeatureTests.test_splitParamArgsProcessorY  s8     ))99!2!2
 	?@r&   c                    \         P                  P                  pV P                  V! R4      R4       V P	                  \
        VR4       V P                  V! R4      RRRR/4       R# )	z
L{ServerSupportedFeatures._parsePrefixParam} parses the ISUPPORT PREFIX
parameter into a mapping from modes to prefix symbols, returns
L{None} if there is no parseable prefix parameter or raises
C{ValueError} if the prefix parameter is malformed.
r*   Nr   z(ov)@+ov@rq   )r3   rv   )r   r  _parsePrefixParamr   r,   r  )r   r6  s   & r   test_parsePrefixParam1ServerSupportedFeatureTests.test_parsePrefixParamd  s^      77II*2.5*&7A*84sHc86TUr&   c                8   \         P                  P                  pV P                  V! . RO4      RRRRRRRR/4       V P                  V! . RO4      RRRRRRRR	/4       V P                  V! . RO4      RRRRRRRR/4       V P	                  \
        V. RO4       R
# )a  
L{ServerSupportedFeatures._parseChanModesParam} parses the ISUPPORT
CHANMODES parameter into a mapping from mode categories to mode
characters. Passing fewer than 4 parameters results in the empty string
for the relevant categories. Passing more than 4 parameters raises
C{ValueError}.
r*   addressModesr   setParamnoParamr   re   rf   imnpstN)r*   r*   r*   r*   )r   re   rf   r=  )r   re   rf   r*   )r   r   cde)r   r  _parseChanModesParamr   r,   r  )r   rA  s   & r   test_parseChanModesParam4ServerSupportedFeatureTests.test_parseChanModesParamp  s      #::OO !12R"j"iL	

 	 !:;S'3
CHU	

 	 !45S'3
CBO	

 	*&:<UVr&   c                l   \         P                  ! 4       pVP                  . R
O4       V P                  VP	                  R4      ^4       V P                  VP	                  R4      RR.4       V P                  VP	                  R4      R4       V P                  VP	                  R4      R4       V P                  VP	                  R4      R4       V P                  VP                  R4      4       VP                  R.4       V P                  VP                  R4      4       VP                  R.4       R	# )z
L{ServerSupportedFeatures.parse} changes the internal state of the
instance to reflect the features indicated by the parsed ISUPPORT
parameters, including unknown parameters and unsetting previously set
parameters.
INVEXMODES	CHANLIMITIEXCEPTSZUNKNOWNz-INVEXN)MODES=4zCHANLIMIT=#:20,&:10rE  z	EXCEPTS=ZzUNKNOWN=A,B,C)#   )&
   )r   r(  r)  )r   r  parser   
getFeature
assertTrue
hasFeatureassertFalse)r   	supporteds   & r   
test_parse&ServerSupportedFeatureTests.test_parse  s     //1	U	
 	--g6:--k:Y	<RS--g6<--i8#>--i8/J	,,W56
#--g67
#r&   c           	         \         P                  ! 4       pV UUu. uF   w  r4RP                  Y4;'       g    R4      NK"  	  pppVP                  V4       V# u uppi )z
Parse all specified features according to the ISUPPORT specifications.

@type features: C{list} of C{(featureName, value)}
@param features: Feature names and values to parse

@rtype: L{irc.ServerSupportedFeatures}
z{}={}r*   )r   r  formatrQ  )r   featuresrV  r   values   &&   r   _parse"ServerSupportedFeatureTests._parse  sO     //1	IQR+$GNN4"5R! Ss
   AANc                J    V P                  W3.4      pVP                  V4      # )zw
Parse a feature, with the given name and value, according to the
ISUPPORT specifications and return the parsed value.
)r]  rR  )r   r   r\  rV  s   &&& r   _parseFeature)ServerSupportedFeatureTests._parseFeature  s'    
 KK$0	##D))r&   c                    V P                  V P                  VR4      V4       V P                  V P                  VR4      V4       V P                  V P                  VR4      ^*4       R# )zG
Perform some common tests on a feature known to use L{_intOrDefault}.
Nnotanintrc   r   r`  )r   r   defaults   &&&r   _testIntOrDefaultFeature4ServerSupportedFeatureTests._testIntOrDefaultFeature  s[     	++D$7A++D*=wG++D$7<r&   c                   \         P                  ! 4       P                  V,          pVf   R.pV P                  V4      pV P	                  VP                  V4      4       V P                  VP                  V4      V4       R# )z
Features known to have default values are reported as being present by
L{irc.ServerSupportedFeatures.hasFeature}, and their value defaults
correctly, when they don't appear in an ISUPPORT message.
N)DEFINITELY_NOT	a_feature)r   r  	_featuresr]  rS  rT  r   rR  )r   r   r[  re  rV  s   &&&  r   _testFeatureDefault/ServerSupportedFeatureTests._testFeatureDefault  sk     --/99$?78HKK)		,,T23--d3W=r&   c                p   V P                  R4       V P                  RR.4       V P                  RR.4       V P                  V P                  RR4      RRRRRRRR/4       V P                  V P                  RR4      RRRR	RRRR/4       V P                  V P                  RR
4      RR	RRRRRR/4       R# )z
The CHANMODES ISUPPORT parameter is parsed into a C{dict} giving the
four mode categories, C{'addressModes'}, C{'param'}, C{'setParam'}, and
C{'noParam'}.
	CHANMODESz,,,r:  r*   r   r;  r<  z,A,,r   zA,Bc,Def,GhijBcDefGhijN)ro  zb,,lk,)ro  zb,,lk,ha,harl  r   r`  r/   s   &r   test_support_CHANMODES2ServerSupportedFeatureTests.test_support_CHANMODES  s     	  -  /F.GH  /K.LM{E2R"j"iL	

 	{F3R#z2y"M	

 	{O<S'4UIvV	
r&   c                L    V P                  V P                  RR4      R.4       R# )zq
The IDCHAN support parameter is parsed into a sequence of two-tuples
giving channel prefix and ID length pairs.
IDCHANz!:5N)!5rd  r/   s   &r   test_support_IDCHAN/ServerSupportedFeatureTests.test_support_IDCHAN  s#    
 	++He<zlKr&   c                    V P                  V P                  RR4      RR.4       V P                  V P                  RR4      . RO4       V P                  V P                  RR4      . RO4       R# )	zf
The MAXLIST support parameter is parsed into a sequence of two-tuples
giving modes and their limits.
MAXLISTz
b:25,eI:50zb:25,eI:50,a:3.1415Nzb:25,eI:50,a:notanintr      eI2   )r~  r  )r   Nrd  r/   s   &r   test_support_MAXLIST0ServerSupportedFeatureTests.test_support_MAXLIST  sq    
 	y,7)Z9P	
 	y*?@0	
 	y*AB0	
r&   c                J    V P                  V P                  RR4      R4       R# )zZ
The NETWORK support parameter is parsed as the network name, as
specified by the server.
NETWORKIRCNetNrd  r/   s   &r   test_support_NETWORK0ServerSupportedFeatureTests.test_support_NETWORK  s!    
 	++Ix@(Kr&   c                H    V P                  V P                  R4      R4       R# )zy
The SAFELIST support parameter is parsed into a boolean indicating
whether the safe "list" command is supported or not.
SAFELISTTNrd  r/   s   &r   test_support_SAFELIST1ServerSupportedFeatureTests.test_support_SAFELIST  s    
 	++J7>r&   c                J    V P                  V P                  RR4      R4       R# )z}
The STATUSMSG support parameter is parsed into a string of channel
status that support the exclusive channel notice method.
	STATUSMSGz@+Nrd  r/   s   &r   test_support_STATUSMSG2ServerSupportedFeatureTests.test_support_STATUSMSG  s!    
 	++K>Er&   c           	         V P                  V P                  RR4      R^R^/4       V P                  V P                  RR4      R^R^RR/4       V P                  V P                  RR4      R^R^RR/4       R# )	z
The TARGMAX support parameter is parsed into a dictionary, mapping
strings to integers, of the maximum number of targets for a particular
command.
TARGMAXzPRIVMSG:4,NOTICE:3PRIVMSGNOTICEzPRIVMSG:4,NOTICE:3,KICK:3.1415KICKNz PRIVMSG:4,NOTICE:3,KICK:notanintrd  r/   s   &r   test_support_TARGMAX0ServerSupportedFeatureTests.test_support_TARGMAX  s     	y*>?8Q'	

 	y*JK8Q5	
 	y*LM8Q5	
r&   c                v    \         P                  ! 4       P                  R,          pV P                  RV4       R# )z
The NICKLEN support parameter is parsed into an integer value
indicating the maximum length of a nickname the client may use,
otherwise, if the parameter is missing or invalid, the default value
(as specified by RFC 1459) is used.
NICKLENNr   r  rk  rf  r   re  s   & r   test_support_NICKLEN0ServerSupportedFeatureTests.test_support_NICKLEN*  s-     --/99)D%%i9r&   c                v    \         P                  ! 4       P                  R,          pV P                  RV4       R# )z
The CHANNELLEN support parameter is parsed into an integer value
indicating the maximum channel name length, otherwise, if the
parameter is missing or invalid, the default value (as specified by
RFC 1459) is used.

CHANNELLENNr  r  s   & r   test_support_CHANNELLEN3ServerSupportedFeatureTests.test_support_CHANNELLEN4  s-     --/99,G%%lG<r&   c                l    V P                  R4       V P                  V P                  RR4      R4       R# )z\
The CHANTYPES support parameter is parsed into a tuple of
valid channel prefix characters.
	CHANTYPESz#&%N)rM  rO  r9   rs  r/   s   &r   test_support_CHANTYPES2ServerSupportedFeatureTests.test_support_CHANTYPES>  s/    
 	  -++K?Qr&   c                (    V P                  R4       R# )z
The KICKLEN support parameter is parsed into an integer value
indicating the maximum length of a kick message a client may use.
KICKLENNrf  r/   s   &r   test_support_KICKLEN0ServerSupportedFeatureTests.test_support_KICKLENG  s    
 	%%i0r&   c           	     2   V P                  R4       V P                  RR.4       V P                  V P                  RR4      R4       V P                  V P                  RR4      RR	RR
RR/4       V P                  V P                  RR4      RR
RR	RR/4       R# )zu
The PREFIX support parameter is parsed into a dictionary mapping
modes to two-tuples of status symbol and priority.
PREFIXNz(ohv)@%+r2  hr3  z(hov)@%+)r  r   r4  )r9   rv   )r3   rw   rs  r/   s   &r   test_support_PREFIX/ServerSupportedFeatureTests.test_support_PREFIXN  s    
 	  *  ,?+@A++Hd;TBx4(C39	
 	x4(C39	
r&   c                (    V P                  R4       R# )z{
The TOPICLEN support parameter is parsed into an integer value
indicating the maximum length of a topic a client may set.
TOPICLENNr  r/   s   &r   test_support_TOPICLEN1ServerSupportedFeatureTests.test_support_TOPICLEN`  s    
 	%%j1r&   c                (    V P                  R4       R# )a/  
The MODES support parameter is parsed into an integer value
indicating the maximum number of "variable" modes (defined as being
modes from C{addressModes}, C{param} or C{setParam} categories for
the C{CHANMODES} ISUPPORT parameter) which may by set on a channel
by a single MODE command from a client.
rF  Nr  r/   s   &r   test_support_MODES.ServerSupportedFeatureTests.test_support_MODESg  s     	%%g.r&   c                    V P                  V P                  RR4      R4       V P                  V P                  R4      R4       R# )z
The EXCEPTS support parameter is parsed into the mode character
to be used for "ban exception" modes. If no parameter is specified
then the character C{e} is assumed.
rI  rJ  r@  Nrd  r/   s   &r   test_support_EXCEPTS0ServerSupportedFeatureTests.test_support_EXCEPTSq  s<     	++Is;SA++I6<r&   c                    V P                  V P                  RR4      R4       V P                  V P                  R4      R4       R# )z
The INVEX support parameter is parsed into the mode character to be
used for "invite exception" modes. If no parameter is specified then
the character C{I} is assumed.
rE  rJ  rH  Nrd  r/   s   &r   test_support_INVEX.ServerSupportedFeatureTests.test_support_INVEXz  s<     	++GS93?++G4c:r&   r   N)"r   r   r    r!   rl   r  r"  r,  r/  r7  rB  rW  r]  r`  rf  rl  rt  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r#   r$   s   @r   r  r  "  s     
6C:N	A
VW4$0*=>
2L
$L?F
(:=R1
$2/=; ;r&   r  c                       ] tR tRt^ tRtR# )IRCClientWithoutLogini  r   N)r   r   r    r!   performLoginr"   r   r&   r   r  r    s    Lr&   r  c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )	CTCPTestsi  zC
Tests for L{twisted.words.protocols.irc.IRCClient} CTCP handling.
c                l   \        4       V n        \        P                  ! V P                  4      V n        \        4       V n        V P                  P                  V P                  4       V P                  V P                  P                  4       V P                  V P                  P                  R 4       R # r  )r   filer   FileWrapper	transportr  clientmakeConnection
addCleanuploseConnectionconnectionLostr/   s   &r   setUpCTCPTests.setUp  sp    *,	!--dii8+-""4>>255622D9r&   c                   RR\         P                  R\         P                  \         P                  ,           /,          pRR\         P                  R\         P                  \         P                  ,           /,          pV P                  P                  V4       V P                  P                  4       pV P                  W24       R# )zTesting CTCP query ERRMSG.

Not because this is this is an especially important case in the
field, but it does go through the entire dispatch/decode/encode
process.
z@:nick!guy@over.there PRIVMSG #theChan :%(X)cERRMSG t%(X)c%(EOL)sr   EOLz>NOTICE nick :%(X)cERRMSG t :No error has occurred.%(X)c%(EOL)sN)	r   X_DELIMr   LFr  dataReceivedr  getvaluer   )r   errQueryerrReplyreplys   &   r   test_ERRMSGCTCPTests.test_ERRMSG  s    (+.UCFFSVVO*TU 	1CKK89 	 	  *		""$##E4r&   c                `   RV P                   n        V P                   P                  RRR4       RR\        P                  R\        P
                  \        P                  ,           RV P                   P                  /,          pV P                  P                  4       pV P                  W!4       R# )	z
If attributes for version information on L{IRCClient} are set to
L{None}, the parts of the CTCP VERSION response they correspond to
are omitted.

FrobozzIRCnick!guy@over.there#theChanNz1NOTICE nick :%(X)cVERSION %(vname)s::%(X)c%(EOL)sr   r  vname)
r  versionNamectcpQuery_VERSIONr   r  r   r  r  r  r   r   versionReplyr  s   &  r   test_noNumbersVERSIONCTCPTests.test_noNumbersVERSION  s     #/%%&;ZNM366CFF?T[[,,Q
 

 		""$##E8r&   c                   RV P                   n        RV P                   n        RV P                   n        V P                   P	                  RRR4       RR\
        P                  R	\
        P                  \
        P                  ,           R
V P                   P                  RV P                   P                  RV P                   P                  /,          pV P                  P                  4       pV P                  W!4       R# )z
The response to a CTCP VERSION query includes the version number and
environment information, as specified by L{IRCClient.versionNum} and
L{IRCClient.versionEnv}.
r  z1.2gZorkOSr  r  NzANOTICE nick :%(X)cVERSION %(vname)s:%(vnum)s:%(venv)s%(X)c%(EOL)sr   r  r  vnumvenv)r  r  
versionNum
versionEnvr  r   r  r   r  r  r  r   r  s   &  r   test_fullVERSIONCTCPTests.test_fullVERSION  s     #/!'!)%%&;ZN S[[svv00.... 	 		""$##E8r&   c                H  a  V 3R lp^ S n         VS P                  n        S P                  P                  RRRP	                  \
        P                  R7      .4       S P                  S P                  P                  4       R4       S P                  S P                   ^4       R# )z<
Duplicated CTCP messages are ignored and no reply is made.
c                 :   < S;P                   ^,          un         R# rv   N)called)userchanneldatar   s   &&&r   testCTCP8CTCPTests.test_noDuplicateCTCPDispatch.<locals>.testCTCP  s    KK1Kr&   foo!bar@baz.quux#chanz{X}TESTTHIS{X}foo{X}TESTTHIS{X}r   r*   N)r  r  ctcpQuery_TESTTHISirc_PRIVMSGrZ  r   r  r   r  r  r   )r   r  s   f r   test_noDuplicateCTCPDispatch&CTCPTests.test_noDuplicateCTCPDispatch  s    
	 )1&7>>>MN	
 	##DII$6$6$8"=a(r&   c                H  a  V 3R lp^ S n         S P                  S P                  RV4       S P                  P                  RRRP	                  \
        P                  R7      .4       S P                  S P                  P                  4       R4       S P                  S P                  R
4       S P                  S P                   ^4       S P                  P                  RRR	P	                  \
        P                  R7      .4       S P                  S P                   ^4       R# )zA
The fallback handler is invoked for unrecognized CTCP messages.
c                 L   < WW#3Sn         S;P                  ^,          un        R# r  )
calledWithr  )r  r  tagr  r   s   &&&&r   unknownQuery6CTCPTests.test_noDefaultDispatch.<locals>.unknownQuery  s    #c8DOKK1Kr&   ctcpUnknownQueryr  r  z{X}NOTREAL{X}r  r*   Nz{X}NOTREAL{X}foo{X}NOTREAL{X})r  r  NOTREALN)r  patchr  r  rZ  r   r  r   r  r  r   r  )r   r  s   f r   test_noDefaultDispatch CTCPTests.test_noDefaultDispatch  s    
	 

4;; 2LA/*@*@3;;*@*O P	
 	##DII$6$6$8"=OOK	
 	a( 	5<<s{{<KL	
 	a(r&   )r  r  r  r  r  N)r   r   r    r!   rl   r  r  r  r  r  r  r"   r#   r$   s   @r   r  r    s-     :509 90)$) )r&   r  c                      a a ] tR tRt o/ RRbRR bRR!bRR bRR bRR"bRR#bR	R$bR
R bRR%bRR&bRR'bRR'bRR&bRR(bRR)bRR*bRR+RR,RR-RR-RR.RR/RR0RR1/CtR tV 3R ltR tRtVt	V ;t
# )2NoticingClienti  createdyourHostmyInfoluserClientbounceisupportluserChannelsluserOpluserMereceivedMOTDprivmsgjoinedleftnoticedmodeChangedpongsignedOn
kickedFromnickChanged
userJoineduserLeft
userKickedactiontopicUpdateduserRenamedc                    . V n         R # r  calls)r   r   kws   &*,r   __init__NoticingClient.__init__"  s     
r&   c                  < VP                  R 4      '       d'   VP                  R 4      '       d   \        SV `  V4      #  \        SV `  R4      V,          pV P	                  W4      #   \
         d    \        ST `  T4      u # i ; i)__methods)
startswithendswithsuper__getattribute__
makeMethodKeyError)r   r   r  	__class__s   && r   r/  NoticingClient.__getattribute__*  s{    ??4  T]]4%8%87+D11	/7+I6t<D ??4..  	27+D11	2s    A' 'BBc                   a aa VVV 3R  lpV# )c                    < \        V 4      \        S4      8  d(   \        R S\        S4      \        V 4      3,          4      h\        SV 4       F#  w  r#W!9   d   \        RS: RV: R24      hW1V&   K%  	  \        V4      \        S4      8w  d(   \        R S\        S4      \        V 4      3,          4      hSP                  P	                  SV34       R# )z-TypeError: %s() takes %d arguments (%d given)zTypeError: z-() got multiple values for keyword argument ''N)len	TypeErrorzipr%  append)r   r&  r   r\  r  fnamer   s   *,  r   method)NoticingClient.makeMethod.<locals>.method5  s    1vD	!!$)3t9c!f#=>   #4|:#7<dD 
  %tH  , 2w#d)#!$)3t9c!f#=>  JJubk*r&   r   )r   r;  r  r<  s   fff r   r0  NoticingClient.makeMethod4  s    	+* r&   r$  wheninfo
servernameversionumodescmodes)options)channels)ops)motd)r  r  message)r  )r  r  setmodesr  )r  secsr   )r  kickerrL  nick)r  r  )r  r  rP  rL  )r  r  r  )r  r  newTopic)oldnamenewname)r   r   r    r!   r+  r'  r/  r0  r"   r#   __classcell__)r2  r%   s   @@r   r	  r	    s#    9I 	? 	y	
 	) 	L 	 	8 	9 		 	1 	, 	 	1 	B  	 !" 	B#$ 	6y)'>-7-3G8/ r&   r	  c                 B     W,          pW V#   \          d    Tu # i ; ir  )r1  )dictkeyre  r\  s   &&& r   poprZ  M  s0    	 I	  s    c                      a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR"R ltR#R ltR#R ltR tR tR tR tR tR tR tR t R  t!R!t"V t#R# )$ClientImplementationTestsiW  c                "   \        4       V n        \        4       V n        V P                  P	                  V P                  4       V P                  V P                  P                  4       V P                  V P                  P                  R 4       R # r  )r   r  r	  r  r  r  r  r  r/   s   &r   r  ClientImplementationTests.setUpX  sZ    (*$&""4>>255622D9r&   c                j   \        VR R4      p\        VRR4      p\        VRR4      pRV,           R,           V,           R,           V,           R,           V,           R,           V,           R	,           pV P                  P                  V4       V P                  V P                  P                  W43.4       R
# )hostserver.hostrR  nicknamer  r*   :  :
NrZ  r  r  r   r%  )	r   codemsgfuncr&  r`  rR  r  rL  s	   &&&&,    r   _serverTestImpl)ClientImplementationTests._serverTestImpl`  s    2v}-2vz*2vr" $Jt#c)D036=DsJVS 	 	  )**dZL9r&   c                4    R pV P                  RVRVR7       R# )zHYour host is some.host[blah.blah/6667], running version server-version-3002r  rA  Nrk  r   ri  s   & r   testYourHost&ClientImplementationTests.testYourHostl  s    XUC#>r&   c                4    R pV P                  RVRVR7       R# )z=This server was cobbled together Fri Aug 13 18:00:25 UTC 2004003r
  r?  Nro  rp  s   & r   testCreated%ClientImplementationTests.testCreatedp  s    MUC=r&   c           
     :    R pV P                  RVRRRRRR7       R# )	z(server.host server-version abcDEF bcdEHI004r  ra  zserver-versionabcDEFbcdEHIrC  Nro  rp  s   & r   
testMyInfo$ClientImplementationTests.testMyInfot  s/    8$$ 	 	
r&   c                4    R pV P                  RVRVR7       R# )z4There are 9227 victims and 9542 hiding on 24 servers251r  rA  Nro  rp  s   & r   testLuserClient)ClientImplementationTests.testLuserClient  s    DUCSAr&   c                >    R pRpV P                  RVRV. ROR7       R# )zMODES=4 CHANLIMIT=#:20 NICKLEN=16 USERLEN=10 HOSTLEN=63 TOPICLEN=450 KICKLEN=450 CHANNELLEN=30 KEYLEN=23 CHANTYPES=# PREFIX=(ov)@+ CASEMAPPING=ascii CAPAB IRCD=dancerare available on this server005r  r  rH  N)rL  zCHANLIMIT=#:20z
NICKLEN=16z
USERLEN=10z
HOSTLEN=63zTOPICLEN=450zKICKLEN=450zCHANNELLEN=30z	KEYLEN=23zCHANTYPES=#zPREFIX=(ov)@+zCASEMAPPING=asciiCAPABzIRCD=dancerro  r   r  ri  s   &  r   _sendISUPPORT'ClientImplementationTests._sendISUPPORT  s8    @ 	
 - 	 	
r&   c                &    V P                  4        R# )zY
The client parses ISUPPORT messages sent by the server and calls
L{IRCClient.isupport}.
N)r  r/   s   &r   test_ISUPPORT'ClientImplementationTests.test_ISUPPORT  s    
 	r&   c                4    R pV P                  RVRVR7       R# )zTry server some.host, port 321010r  rA  Nro  rp  s   & r   
testBounce$ClientImplementationTests.testBounce  s    .UC<r&   c           	     L    R pRpV P                  RVRV\        V4      R7       R# )7116zchannels formed254r  )r  rI  Nrk  intr  s   &  r   testLuserChannels+ClientImplementationTests.testLuserChannels  s*    UCtcRViXr&   c           	     L    R pRpV P                  RVRV\        V4      R7       R# )34zflagged staff members252r  )r  rJ  Nr  r  s   &  r   testLuserOp%ClientImplementationTests.testLuserOp  s)    %UC3t9Mr&   c                4    R pV P                  RVRVR7       R# )z!I have 1937 clients and 0 servers255r  rA  Nro  rp  s   & r   testLuserMe%ClientImplementationTests.testLuserMe  s    1UC=r&   c                V   . ROpV FK  pV P                  V P                  P                  . 4       V P                  P                  VR,           4       KM  	  V P                  V P                  P                  RRRR./3.4       V P	                  V P                  P
                  R4       R# )z
Lines received in I{RPL_MOTDSTART} and I{RPL_MOTD} are delivered to
L{IRCClient.receivedMOTD} when I{RPL_ENDOFMOTD} is received.
rf  r  rK  zhost.name Message of the Day -Welcome to host.nameN)z9:host.name 375 nickname :- host.name Message of the Day -/:host.name 372 nickname :- Welcome to host.name.:host.name 376 nickname :End of /MOTD command.)r   r  r%  r  assertIdenticalrK  r   linesLs   &  r   test_receivedMOTD+ClientImplementationTests.test_receivedMOTD  s    


 AT[[..3KK$$QZ0  	KK #<2!
	
" 	T[[--t4r&   c                    RR.pV F%  pV P                   P                  VR,           4       K'  	  V P                  V P                   P                  RRR./3.4       R# )z
If L{IRCClient} receives I{RPL_MOTD} and I{RPL_ENDOFMOTD} without
receiving I{RPL_MOTDSTART}, L{IRCClient.receivedMOTD} is still
called with a list of MOTD lines.
r  r  rf  r  rK  r  N)r  r  r   r%  r  s   &  r   test_withoutMOTDSTART/ClientImplementationTests.test_withoutMOTDSTART  sc     ><

 AKK$$QZ0  	KK&;Q:R1S TU	
r&   c                   \        VR R 4      p\        VRR4      pVR,           V,           R,           V,           p	RV	,           R,           V,           R,           V,           R,           V,           R,           p
V P                  P                  V
4       V P                  V P                  P                  WV3.4       . V P                  n        R# )	identr`  rx  r5  rc  rd  re  rf  Nrg  )r   sendergrouptyperi  rj  r&  r  r`  	wholeUserrL  s   &&&&&&,    r   _clientTestImpl)ClientImplementationTests._clientTestImpl  s    B)2vv&SL5(3.5		/C'$.4u<tCcIFR  )**dZL9r&   c                v    R pV P                  RRRVRRRRRVR7
       V P                  RR	RVRRRRR	VR7
       R
# )zTooty toot toot.r  z#groupr  r  r  r`  zsender!ident@host)r  r`  r  r  rL  	recipientN)r  rp  s   & r   testPrivmsg%ClientImplementationTests.testPrivmsg  sk     $ 	 	
 	$ 	 	
r&   c                  a  \        \        S P                  P                  4       4      w  rS P	                  V. RO4       S P	                  V. RO4       V 3R lpV! R4       \        \        S P                  P                  4       4      w  rS P	                  V. RO4       S P	                  V. RO4       V! R4       \        \        S P                  P                  4       4      w  rS P	                  V. 4       S P	                  V. 4       S P                  4        S P                  S P                  P                  P                  R4      R4       R# )z
L{IRCClient.getChannelModeParams} uses ISUPPORT information, either
given by the server or defaults, to determine which channel modes
require arguments when being added or removed.
c                    < R V ,           p RpSP                  RVRW .R7       SP                  SP                  P                  P	                  V 4      R4       . SP                  n        R# )r4   r  r  r  r  N)rk  r  r  rV  rR  r%  )r   ri  r   s   & r   removeFeatureJClientImplementationTests.test_getChannelModeParams.<locals>.removeFeature   s[    :D0C  ZdF S  !6!6!A!A$!GN "DKKr&   ro  r  N)r   r  re   rf   r2  r3  )r   r  r2  r3  )r  r2  r3  )	mapsortedr  getChannelModeParamsr   r  assertNotIdenticalrV  rR  )r   addremover  s   f   r   test_getChannelModeParams3ClientImplementationTests.test_getChannelModeParams  s    &$++"B"B"DE<=!56	# 	k"&$++"B"B"DEo.1 	h&$++"B"B"DEb!$ 	 5 5 @ @ JDQr&   c                    \        \        V P                  P                  4       4      w  rV P	                  V. 4       V P	                  V. 4       R# )z
L{IRCClient.getUserModeParams} returns a list of user modes (modes that
the user sets on themself, outside of channel modes) that require
parameters when added and removed, respectively.
N)r  r  r  getUserModeParamsr   )r   r  r  s   &  r   test_getUserModeParams0ClientImplementationTests.test_getUserModeParams8  s?     &$++"?"?"ABb!$r&   Nc                `    Vf   RpRV RV RV R2pV P                   P                  V4       R# )z0
Build a MODE string and send it to the client.
Nr  z:Wolf!~wolf@yok.utu.fi MODE rd  rf  )r  r  )r   ri  r  targetrL  s   &&&& r   _sendModeChange)ClientImplementationTests._sendModeChangeB  s:     >F0#avTJ  )r&   c                6  a Vf   Rp\        V4       F  w  r4Vw  poV P                  VR4       V P                  SR,          R4       V P                  SR,          V4       \        ;QJ d    . V3R lR 4       F  NK  	  5M! V3R lR 4       4      W&   K  	  V# )z?
Parse the results, do some test and return the data to check.
r  r  r  Wolf!~wolf@yok.utu.fir  c              3   6   <"   T F  pSV,          x  K  	  R # 5ir  r   ).0rY  r  s   & r   	<genexpr>=ClientImplementationTests._parseModeChange.<locals>.<genexpr>W  s     M4LStCyy4Ls   )rM  rN  r  )	enumerater   tuple)r   resultsr  rN   resultr<  r  s   &&&   @r   _parseModeChange*ClientImplementationTests._parseModeChangeK  s     >F"7+IA!LFDV]3T&\+BCT)_f5M4LMM4LMMGJ , r&   c                    V P                  V P                  P                  V4      pV P                  W14       . V P                  n        R# )zB
Compare the expected result with the one returned by the client.
N)r  r  r%  r   )r   r!  r  r  s   &&& r   _checkModeChange*ClientImplementationTests._checkModeChangeZ  s:     &&t{{'8'8&A*r&   c                L    V P                  R4       V P                  R.4       R# )zu
Mode strings that do not begin with a directional character, C{'+'} or
C{'-'}, have C{'+'} automatically prepended.
rC   N)TrC   r  r  r  r/   s   &r   test_modeMissingDirection3ClientImplementationTests.test_modeMissingDirectionb  s$    
 	S!345r&   c                    V P                  R4       V P                  R.4       V P                  R4       V P                  R.4       R# )z`
No parameters are passed to L{IRCClient.modeChanged} for modes that
don't take any parameters.
rA   Nz+n)FrC   r  )TrN   r  r  r/   s   &r   test_noModeParameters/ClientImplementationTests.test_noModeParametersj  sD    
 	T"456T"345r&   c                    V P                  RR4       V P                  R.4       V P                  RR4       V P                  R.4       R# )zS
Parameters are passed to L{IRCClient.modeChanged} for modes that take
parameters.
+oa_userz-oN)Tr2  r  )Fr2  r  r  r/   s   &r   test_oneModeParameter/ClientImplementationTests.test_oneModeParametert  sH    
 	T8,789T8,89:r&   c                    V P                  RR4       V P                  R.4       V P                  RR4       V P                  RR.4       R# )z
Mixing adding and removing modes that do and don't take parameters
invokes L{IRCClient.modeChanged} with mode characters and parameters
that match up.
z+osvza_user another_userNz+v-os)Tosv)r  Nanother_user)Tr3  r  )Fos)r  Nr  r/   s   &r   test_mixedModes)ClientImplementationTests.test_mixedModes~  sO     	V%:;NOPW&;<%'LM	
r&   c                   V P                  RR4       V P                  . 4       V P                  \        P                  4      pV P                  \        V4      ^4       V P                  RV^ ,          P                  4       4       R# )z
Passing an argument to modes that take no parameters results in
L{IRCClient.modeChanged} not being called and an error being logged.
r@   r   zToo many parametersN	r  r  flushLoggedErrorsr   r-   r   r7  assertSubstringgetErrorMessager   errorss   & r   test_tooManyModeParameters4ClientImplementationTests.test_tooManyModeParameters  sh    
 	T7+b!''8Va(2F1I4M4M4OPr&   c                   V P                  R4       V P                  . 4       V P                  \        P                  4      pV P                  \        V4      ^4       V P                  RV^ ,          P                  4       4       R# )z
Passing no arguments to modes that do take parameters results in
L{IRCClient.modeChange} not being called and an error being logged.
r  zNot enough parametersNr  r  s   & r   test_tooFewModeParameters3ClientImplementationTests.test_tooFewModeParameters  sf    
 	T"b!''8Va(4fQi6O6O6QRr&   c                   V P                   P                  pV P                  RVR7       V P                  R.VR7       R pV P	                  V P                   RV4       V P                  RRVR7       V P                  R	.VR7       R# )
z
A C{MODE} message whose target is our user (the nickname of our user,
to be precise), as opposed to a channel, will be parsed according to
the modes specified by L{IRCClient.getUserModeParams}.
r  )r  Nc                  
    R R.# )rJ  r*   r   r   r&   r   r  BClientImplementationTests.test_userMode.<locals>.getUserModeParams  s    9r&   r  z+Zan_arg)Tr2  r  )TrJ  )r  )r  rb  r  r  r  )r   r  r  s   &  r   test_userMode'ClientImplementationTests.test_userMode  s     %% 	T&134VD	 	

4;; 35FGT8F;78Hr&   c                  a  V 3R lp\         P                  ! 4       S n        S P                  P                  S n        S P                  S P                  RV4       S P                  S P                  P                  R4       S P                  P                  R. 4       S P                  S P                  P                  R4       S P                  S P                  P                  R4       S P                  S P                  P                  4       R4       S P                  P!                  S P                  P"                  4       S P                  S P                  P                  4       R4       S P                  P%                  4        S P                  P'                  R4       S P                  \)        S P                  P+                  4       4      ^ 4       S P                  S P                  P                  R4       R# )z
When the I{RPL_WELCOME} message is received a heartbeat is started that
will send a I{PING} message to the IRC server every
L{irc.IRCClient.heartbeatInterval} seconds. When the transport is
closed the heartbeat looping call is stopped too.
c                  J   < SP                  4       p SP                  V n        V # r  )_originalCreateHeartbeatclock)	heartbeatr   s    r   _createHeartbeatBClientImplementationTests.test_heartbeat.<locals>._createHeartbeat  s"    557I"jjIOr&   r  Nr8   r*   z
PING foo
)r   Clockr  r  r  r  r  r  
_heartbeatirc_RPL_WELCOMEr  r   hostnamer   r  r\  advanceheartbeatIntervalr  r  r7  getDelayedCalls)r   r  s   f r   test_heartbeat(ClientImplementationTests.test_heartbeat  sY   	
 ZZ\
(,(D(D%

4;; 24DET[[33T:##E2. 6 6=--u5 	##DNN$8$8$:B?

4;;889##DNN$8$8$:NK 	%%'""4(TZZ779:A>T[[33T:r&   c                    V P                  V P                  P                  R4       RV P                  n        V P                  P	                  R. 4       V P                  V P                  P                  R4       R# )zW
If L{irc.IRCClient.heartbeatInterval} is set to L{None} then no
heartbeat is created.
Nr8   )r  r  r	  r  r
  r/   s   &r   test_heartbeatDisabled0ClientImplementationTests.test_heartbeatDisabled  sX    
 	T[[33T:(,%##E2.T[[33T:r&   )r  r  r  r  )r*   Nr  )$r   r   r    r!   r  rk  rq  ru  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r#   r$   s   @r   r\  r\  W  s     :
:?>

B
<=Y
N
>5B
$
< RD%*66;
	Q	SI*;B; ;r&   r\  c                      a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )BasicServerFunctionalityTestsi  c                    \        4       V n        \        P                  ! V P                  4      V n        \
        P                  ! 4       V n        V P                  P                  V P                  4       R # r  )	r   fr   r  rL   r   IRCpr  r/   s   &r   r  #BasicServerFunctionalityTests.setUp  sE    ')%%dff-dff%r&   c                    V P                   P                  4       p\        V\        4      '       d   VP	                  R4      pV P                  W!4       R# )z
Make sure that the internal buffer equals a specified value.

@param s: the value to compare against buffer
@type s: L{bytes} or L{unicode}
r   N)r  r  r   r   r   r   )r   rC   r   s   && r   check#BasicServerFunctionalityTests.check  s?     ffoo'a%,,W5K(r&   c                b    V P                   P                  RRR4       V P                  R4       R# )z
        Passing a command and parameters to L{IRC.sendMessage} results in a
        query string that consists of the command and parameters, separated by
        a space, ending with '
'.
        CMDparam1param2CMD param1 param2
N)r  sendMessager  r/   s   &r   test_sendMessage.BasicServerFunctionalityTests.test_sendMessage  s'     	5(H5

*+r&   c                `    V P                   P                  RR4       V P                  R4       R# )aF  
        Passing a command and parameters to L{IRC.sendCommand} results in a
        query string that consists of the command and parameters, separated by
        a space, ending with '
'.

        The format is described in more detail in
        U{RFC 1459 <https://tools.ietf.org/html/rfc1459.html#section-2.3>}.
        r  r"  Nr   r!  r  sendCommandr  r/   s   &r   test_sendCommand.BasicServerFunctionalityTests.test_sendCommand  s&     	5"67

*+r&   c                `    V P                   P                  RR4       V P                  R4       R# )zS
Passing unicode parameters to L{IRC.sendCommand} encodes the parameters
in UTF-8.
r  s   CMD param¹ param²
N)u   param¹u   param²r(  r/   s   &r   test_sendUnicodeCommand5BasicServerFunctionalityTests.test_sendUnicodeCommand
  s&    
 	5"@A

9:r&   c                    V P                  \        V P                  P                  RRR4      pV P	                  \        V4      R4       R# )zN
Passing L{None} as the command to L{IRC.sendMessage} raises a
C{ValueError}.
Nr   r!  IRC message requires a command.r,   r  r  r#  r   r   r   errors   & r   test_sendMessageNoCommand7BasicServerFunctionalityTests.test_sendMessageNoCommand  s@    
 !!**D(H
 	U%FGr&   c                    V P                  \        V P                  P                  RR4      pV P	                  VP
                  ^ ,          R4       R# )zN
Passing L{None} as the command to L{IRC.sendCommand} raises a
C{ValueError}.
Nr0  r'  r,   r  r  r)  r   r  r2  s   & r   test_sendCommandNoCommand7BasicServerFunctionalityTests.test_sendCommandNoCommand  sC    
 !!**D2F
 	A(IJr&   c                    V P                  \        V P                  P                  RRR4      pV P	                  \        V4      R4       R# )zQ
Passing an invalid string command to L{IRC.sendMessage} raises a
C{ValueError}.
rd  r   r!  zCSomebody screwed up, 'cuz this doesn't look like a command to me:  Nr1  r2  s   & r   test_sendMessageInvalidCommand<BasicServerFunctionalityTests.test_sendMessageInvalidCommand&  sC    
 !!**C8
 	JT	
r&   c                    V P                  \        V P                  P                  RR4      pV P	                  VP
                  ^ ,          R4       R# )zQ
Passing an invalid string command to L{IRC.sendCommand} raises a
C{ValueError}.
rd  zInvalid command: " "Nr'  r7  r2  s   & r   test_sendCommandInvalidCommand<BasicServerFunctionalityTests.test_sendCommandInvalidCommand3  sC    
 !!**C1E
 	A(>?r&   c                b    V P                   P                  RRR4       V P                  R4       R# )z
Passing a command and parameters with a specified prefix to
L{IRC.sendCommand} results in a proper query string including the
specified line prefix.
r  irc.example.com$   :irc.example.com CMD param1 param2
Nr'  r(  r/   s   &r   test_sendCommandWithPrefix8BasicServerFunctionalityTests.test_sendCommandWithPrefix=  s)     	5"68IJ

<=r&   c                N   RRRRRR/pRpV P                   P                  RRRV4       V P                  P                  4       pVP	                  R	^4      w  rEVR
,          P	                  R4      pV P                  VR4       V P                  \        V4      \        V4      4       R# )a  
Passing a command and parameters with a specified prefix and tags
to L{IRC.sendCommand} results in a proper query string including the
specified line prefix and appropriate tags syntax.  The query string
should be output as follows:
@tags :prefix COMMAND param1 param2

The tags are a string of IRCv3 tags, preceded by '@'.  The rest
of the string is as described in test_sendMessage.  For more on
the message tag format, see U{the IRCv3 specification
<https://ircv3.net/specs/core/message-tags-3.2.html>}.
aaabbbcccNzexample.com/dddeeer  rA      rv   NN   ;rB  )   aaa=bbbs   cccs   example.com/ddd=eeer'  r  r)  r  r  splitr   r  r   sendTagsexpectedTagsoutMsg	outTagStroutLineoutTagss   &      r   test_sendCommandWithTags6BasicServerFunctionalityTests.test_sendCommandWithTagsF  s     5%/@%HC5"68I8T"#\\$2	 B-%%d+"KL-vg?r&   c                    RRRRRR/pV P                  \        V P                  P                  RR	RV4      pV P	                  VP
                  ^ ,          R4       R# )
zG
Passing empty tag names to L{IRC.sendCommand} raises a C{ValueError}.
rF  rG  rH  Nr*   r  rA  A tag name is required.r'  r7  r   rQ  r3  s   &  r   !test_sendCommandValidateEmptyTags?BasicServerFunctionalityTests.test_sendCommandValidateEmptyTags_  s]     5%r26!!FF 
 	A(ABr&   c                    RRRRRR/pV P                  \        V P                  P                  RR	RV4      pV P	                  VP
                  ^ ,          R4       R# )
zJ
Passing None as a tag name to L{IRC.sendCommand} raises a
C{ValueError}.
rF  rG  rH  Nbeepr  rA  rZ  r'  r7  r[  s   &  r    test_sendCommandValidateNoneTags>BasicServerFunctionalityTests.test_sendCommandValidateNoneTagsn  s]    
 5%tV<!!FF 
 	A(ABr&   c                    RR/pV P                  \        V P                  P                  RRRV4      pV P	                  VP
                  ^ ,          R4       R# )zT
Passing a tag name containing spaces to L{IRC.sendCommand} raises a
C{ValueError}.
zaaa bbbrH  r  rA   Tag contains invalid characters.Nr'  r7  r[  s   &  r   &test_sendCommandValidateTagsWithSpacesDBasicServerFunctionalityTests.test_sendCommandValidateTagsWithSpaces~  U    
 u%!!FF 
 	A(JKr&   c                    RR/pV P                  \        V P                  P                  RRRV4      pV P	                  VP
                  ^ ,          R4       R# )z`
Passing a tag name containing invalid characters to L{IRC.sendCommand}
raises a C{ValueError}.
zaaa_b^@rH  r  rA  rc  Nr'  r7  r[  s   &  r   ,test_sendCommandValidateTagsWithInvalidCharsJBasicServerFunctionalityTests.test_sendCommandValidateTagsWithInvalidChars  rf  r&   c                &   RRRR/pRpV P                   P                  RRRV4       V P                  P                  4       pVP	                  R^4      w  rEVR,          P	                  R	4      pV P                  \        V4      \        V4      4       R
# )zZ
Tags with values containing invalid characters passed to
L{IRC.sendCommand} are escaped.
rF  rG  rH  z
test
 \;;r  rA  rJ  rK  rL  N)rM  s   ccc=test\r\n\s\\\:\:r'  rN  rP  s   &      r   (test_sendCommandValidateTagValueEscapingFBasicServerFunctionalityTests.test_sendCommandValidateTagValueEscaping  s    
 5%9C5"68I8T"#\\$2	 B-%%d+&*>?r&   c                b    V P                   P                  R RR4       V P                  R4       R# )this-is-senderthis-is-recipzthis is messagez8:this-is-sender PRIVMSG this-is-recip :this is message
N)r  r  r  r/   s   &r   r  )BasicServerFunctionalityTests.testPrivmsg  s%    ':KL

OPr&   c                b    V P                   P                  R RR4       V P                  R4       R# )rn  ro  zthis is noticez6:this-is-sender NOTICE this-is-recip :this is notice
N)r  noticer  r/   s   &r   
testNotice(BasicServerFunctionalityTests.testNotice  %    &9IJ

MNr&   c                b    V P                   P                  R RR4       V P                  R4       R# )rn  ro  zthis is actionz6:this-is-sender ACTION this-is-recip :this is action
N)r  r   r  r/   s   &r   
testAction(BasicServerFunctionalityTests.testAction  ru  r&   c                `    V P                   P                  R R4       V P                  R4       R# )this-personz#this-channelz!:this-person JOIN #this-channel
N)r  joinr  r/   s   &r   testJoin&BasicServerFunctionalityTests.testJoin  !    M?3

89r&   c                `    V P                   P                  R R4       V P                  R4       R# )rz  z#that-channelz!:this-person PART #that-channel
N)r  partr  r/   s   &r   testPart&BasicServerFunctionalityTests.testPart  r~  r&   c                B   \        \        P                  ! 4       ^d,
          4      pV P                  P                  pRpRpV P                  P	                  VVRRRRRR^VR	R
.4       . ROpRP                  V4      \        W!W4R7      ,          pV P                  V4       R# )zX
Verify that a whois by the client receives the right protocol actions
from the server.
zrequesting-nickztarget-nickr  zhost.comzTarget Userzirc.host.comzA fake serverFz
#fakeusersz	#fakemiscrf  )r  	timestampreqtargN)zA:%(hostname)s 311 %(req)s %(targ)s target host.com * :Target Userz>:%(hostname)s 312 %(req)s %(targ)s irc.host.com :A fake serverzN:%(hostname)s 317 %(req)s %(targ)s 12 %(timestamp)s :seconds idle, signon timez8:%(hostname)s 319 %(req)s %(targ)s :#fakeusers #fakemiscz6:%(hostname)s 318 %(req)s %(targ)s :End of WHOIS list.r*   )r  timer  r  whoisr{  rX  r  )r   r  r  r  r  r  r!  s   &      r   	testWhois'BasicServerFunctionalityTests.testWhois  s    
 		c)*	66??;'	

 ;;u%)
 
 	

8r&   )r  r  rL   N)r   r   r    r!   r  r  r$  r*  r-  r4  r8  r;  r>  rC  rW  r\  r`  rd  rh  rk  r  rs  rw  r|  r  r  r"   r#   r$   s   @r   r  r    s     &
),
,;HK
@>@2CC L L @"QOO::! !r&   r  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
DummyClienti  zo
A L{twisted.words.protocols.irc.IRCClient} that stores sent lines in a
C{list} rather than transmitting them.
c                    . V n         R # r  r  r/   s   &r   r'  DummyClient.__init__  s	    
r&   c                R    \         P                  P                  V 4       . V n        R # r  )r   r	   connectionMader  r/   s   &r   r  DummyClient.connectionMade  s    $$T*
r&   c                \    VR\         P                  \        V P                  4      ,
           # )z5
Truncate an IRC line to the maximum allowed length.
N)r   MAX_COMMAND_LENGTHr7  	delimiterr   lines   &&r   _truncateLineDummyClient._truncateLine  s&     Bc,,s4>>/BBCCr&   c                b    V P                  V4      p\        P                  P                  W4      # r  )r  r   r	   lineReceivedr  s   &&r   r  DummyClient.lineReceived  s'    !!$'}}))$55r&   c                Z    V P                   P                  V P                  V4      4       R # r  )r  r:  r  )r   ms   &&r   sendLineDummyClient.sendLine  s    

$,,Q/0r&   r  N)r   r   r    r!   rl   r'  r  r  r  r  r"   r#   r$   s   @r   r  r    s)     
D6
1 1r&   r  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )ClientInviteTestsi  z 
Tests for L{IRCClient.invite}.
c                $    \        4       V n        R# )z?
Create a L{DummyClient} to call C{invite} on in test methods.
N)r  r  r/   s   &r   r  ClientInviteTests.setUp  s     "mr&   c                    V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z{
If the channel name passed to L{IRCClient.invite} does not begin with a
channel prefix character, one is prepended to it.
r8   r  INVITE foo #barNr  inviter   r  r/   s   &r   test_channelCorrection(ClientInviteTests.test_channelCorrection  s6    
 	5%(**->,?@r&   c                    V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z[
L{IRCClient.invite} sends an I{INVITE} message with the specified
username and a channel.
r8   #barr  Nr  r/   s   &r   test_inviteClientInviteTests.test_invite  s6    
 	5&)**->,?@r&   r  N)
r   r   r    r!   rl   r  r  r  r"   r#   r$   s   @r   r  r    s!     $AA Ar&   r  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR R ltR R ltR tR tR tR tR tR tR tR tR tR tRt V t!R# )!ClientMsgTestsi  zH
Tests for messages sent with L{twisted.words.protocols.irc.IRCClient}.
c                X    \        4       V n        V P                  P                  4        R # r  )r  r  r  r/   s   &r   r  ClientMsgTests.setUp$  s    !m""$r&   c                    V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z?
A message containing no newlines is sent in a single command.
r8   r  PRIVMSG foo :barN)r  ri  r   r  r/   s   &r   test_singleLineClientMsgTests.test_singleLine(  s4     	u%**-?,@Ar&   c                    V P                  \        V P                  P                  RR^ 4       V P                  \        V P                  P                  RR^4       R# )z
Specifying a C{length} value to L{IRCClient.msg} that is too short to
contain the protocol command to send a message raises C{ValueError}.
r8   r  N)r,   r  r  ri  r/   s   &r   test_invalidMaxLength$ClientMsgTests.test_invalidMaxLength/  s@    
 	*dkkooueQG*dkkooueQGr&   c                    \        R4      ^,           ^,           pV P                  P                  RRV4       V P                  V P                  P                  . RO4       R# )zo
Messages longer than the C{length} parameter to L{IRCClient.msg} will
be split and sent in multiple commands.
PRIVMSG foo :r8   barbazboN)r  PRIVMSG foo :bazzPRIVMSG foo :bor7  r  ri  r   r  )r   
maxLen_msgs   & r   test_multipleLine_msg$ClientMsgTests.test_multipleLine_msg7  sJ    
 )A-1
z:6KKG	
r&   c                    \        R4      ^,           ^,           pV P                  P                  RRV4       V P                  V P                  P                  . RO4       R# )zr
Messages longer than the C{length} parameter to L{IRCClient.notice}
will be split and sent in multiple commands.
NOTICE foo :r8   r  N)NOTICE foo :barNOTICE foo :bazzNOTICE foo :bor7  r  rr  r   r  )r   maxLen_notices   & r   test_multipleLine_notice'ClientMsgTests.test_multipleLine_noticeC  sL    
 N+a/!35*m<KKD	
r&   c                L   Rp\        RV 24      ^,           pV P                  P                  RW4       V P                  V P                  P                  RV 2.4       . V P                  n        V P                  P                  RW^,
          4       V P                  ^\        V P                  P                  4      4       . V P                  n        V P                  P                  RW^,           4       V P                  ^\        V P                  P                  4      4       R# )zo
Messages exactly equal in length to the C{length} parameter to
L{IRCClient.msg} are sent in a single command.
r  r  r8   Nr  r   ri  maxLens   &  r   test_sufficientWidth_msg'ClientMsgTests.test_sufficientWidth_msgO  s    
 }SE*+a/s+**}SE-B,CDsQJ/C 1 123sQJ/C 1 123r&   c                L   Rp\        RV 24      ^,           pV P                  P                  RW4       V P                  V P                  P                  RV 2.4       . V P                  n        V P                  P                  RW^,
          4       V P                  ^\        V P                  P                  4      4       . V P                  n        V P                  P                  RW^,           4       V P                  ^\        V P                  P                  4      4       R# )zr
Messages exactly equal in length to the C{length} parameter to
L{IRCClient.notice} are sent in a single command.
r  r  r8   Nr  r  s   &  r   test_sufficientWidth_notice*ClientMsgTests.test_sufficientWidth_notice_  s    
 |C5)*Q.5#.**|C5-A,BC5#z2C 1 1235#z2C 1 123r&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z3
An LF at the beginning of the message is ignored.
r8   
barr  Nr  r  ri  r   r/   s   &r   test_newlinesAtStart_msg'ClientMsgTests.test_newlinesAtStart_msgo  @     w'**-?,@Ar&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z2
An LF at the beginning of the notice is ignored.
r8   r  r  Nr  r  rr  r   r/   s   &r   test_newlinesAtStart_notice*ClientMsgTests.test_newlinesAtStart_noticew  B     5'***->,?@r&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z-
An LF at the end of the message is ignored.
r8   bar
r  Nr  r/   s   &r   test_newlinesAtEnd_msg%ClientMsgTests.test_newlinesAtEnd_msg  r  r&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z,
An LF at the end of the notice is ignored.
r8   r  r  Nr  r/   s   &r   test_newlinesAtEnd_notice(ClientMsgTests.test_newlinesAtEnd_notice  r  r&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  RR.4       R# )z+
An LF within a message causes a new line.
r8   bar
bazr  r  Nr  r/   s   &r   test_newlinesWithinMessage_msg-ClientMsgTests.test_newlinesWithinMessage_msg  sC     z***-?AS,TUr&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  RR.4       R# )z*
An LF within a notice causes a new line.
r8   r  r  r  Nr  r/   s   &r   !test_newlinesWithinMessage_notice0ClientMsgTests.test_newlinesWithinMessage_notice  sE     5*-**->@Q,RSr&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  RR.4       R# )z8
Consecutive LFs in messages do not cause a blank line.
r8   bar

bazr  r  Nr  r/   s   &r   test_consecutiveNewlines_msg+ClientMsgTests.test_consecutiveNewlines_msg  sC     |,**-?AS,TUr&   c                    . V P                   n        V P                   P                  RR4       V P                  V P                   P                  RR.4       R# )z7
Consecutive LFs in notices do not cause a blank line.
r8   r  r  r  Nr  r/   s   &r   test_consecutiveNewlines_notice.ClientMsgTests.test_consecutiveNewlines_notice  sE     5,/**->@Q,RSr&   Nc                *  a RP                  V P                  P                  V P                  P                  V P                  P                  4      pV P                  P                  RWR7       . oV P                  V P                  RV3R l4       V P                  P                   F$  pV P                  P                  WE,           4       K&  	  V P                  \        S4      V4       RP                  R S 4       4      pV P                  W4       R# )	z
Assert that messages sent by L{IRCClient.msg} are split into an
expected number of commands and the original message is transmitted in
its entirety over those commands.

:{}!{}@{} r8   lengthr  c                  &   < SP                  V 4      # r  r:  )r   r  s   *r   <lambda>?ClientMsgTests.assertLongMessageSplitting_msg.<locals>.<lambda>  s    gnnQ6Gr&   r*   c              3   *   "   T F	  w  rq3x  K  	  R # 5ir  r   r  r  r  rL  s   &   r   r  @ClientMsgTests.assertLongMessageSplitting_msg.<locals>.<genexpr>  s     !Ow.CdG'w   N)rZ  r  rb  realnamer  ri  r  r  r  r   r7  r{  )r   rL  expectedNumCommandsr  responsePrefixr  receivedMessager  s   &&&&   @r   assertLongMessageSplitting_msg-ClientMsgTests.assertLongMessageSplitting_msg  s     &,,KK  KK  KK  
 	w6

4;;	+GHKK%%DKK$$^%:; & 	W':;''!Ow!OO 	2r&   c                *  a RP                  V P                  P                  V P                  P                  V P                  P                  4      pV P                  P                  RWR7       . oV P                  V P                  RV3R l4       V P                  P                   F$  pV P                  P                  WE,           4       K&  	  V P                  \        S4      V4       RP                  R S 4       4      pV P                  W4       R# )	z
Assert that messages sent by l{IRCClient.notice} are split into an
expected number of commands and the original message is transmitted in
its entirety over those commands.
r  r8   r  r  c                  &   < SP                  V 4      # r  r  )r   rr  s   *r   r  BClientMsgTests.assertLongMessageSplitting_notice.<locals>.<lambda>  s    fmmA6Fr&   r*   c              3   *   "   T F	  w  rq3x  K  	  R # 5ir  r   r  s   &   r   r  CClientMsgTests.assertLongMessageSplitting_notice.<locals>.<genexpr>  s     !Nv.CdG'vr  N)rZ  r  rb  r  r  rr  r  r  r  r   r7  r{  )r   rL  r   r  r  r  r  rr  s   &&&&   @r   !assertLongMessageSplitting_notice0ClientMsgTests.assertLongMessageSplitting_notice  s     &,,KK  KK  KK  
 	5'9

4;;	+FGKK%%DKK$$^%:; & 	V&9:''!Nv!NN 	2r&   c                f    R\         P                  ^,
          ,          pV P                  V^4       R# )a-  
If a maximum message length is not provided to L{IRCClient.msg} a
best-guess effort is made to determine a safe maximum,  messages longer
than this are split into multiple commands with the intent of
delivering long messages without losing data due to message truncation
when the server relays them.
r2  Nr   r  r  r   rL  s   & r   %test_splitLongMessagesWithDefault_msg4ClientMsgTests.test_splitLongMessagesWithDefault_msg  s)     //!34++GQ7r&   c                f    R\         P                  ^,
          ,          pV P                  V^4       R# )a0  
If a maximum message length is not provided to L{IRCClient.notice} a
best-guess effort is made to determine a safe maximum,  messages longer
than this are split into multiple commands with the intent of
delivering long messages without losing data due to message truncation
when the server relays them.
r2  Nr   r  r
  r  s   & r   (test_splitLongMessagesWithDefault_notice7ClientMsgTests.test_splitLongMessagesWithDefault_notice  s)     //!34..w:r&   c                    R\         P                  ^,
          ,          pV P                  V^\         P                  ^,          R7       R# )z
The maximum message length can be specified to L{IRCClient.msg},
messages longer than this are split into multiple commands with the
intent of delivering long messages without losing data due to message
truncation when the server relays them.
r2  r  Nr  r  s   & r   &test_splitLongMessagesWithOverride_msg5ClientMsgTests.test_splitLongMessagesWithOverride_msg  s>     //!34++Qs55: 	, 	
r&   c                    R\         P                  ^,
          ,          pV P                  V^\         P                  ^,          R7       R# )z
The maximum message length can be specified to L{IRCClient.notice},
messages longer than this are split into multiple commands with the
intent of delivering long messages without losing data due to message
truncation when the server relays them.
r2  r  Nr  r  s   & r   )test_splitLongMessagesWithOverride_notice8ClientMsgTests.test_splitLongMessagesWithOverride_notice  s>     //!34..Qs55: 	/ 	
r&   c                   R\         P                  ^,          ,          pV P                  P                  RVR,           V,           4       V P	                  V P                  P
                  RV,           RV,           .4       R# )z;
IRCClient breaks on newlines before it breaks long lines.
r2  r8   
r  Nr   r  r  ri  r   r  r   longlines   & r   test_newlinesBeforeLineBreaking.ClientMsgTests.test_newlinesBeforeLineBreaking  s`     #00A56x$9:KK( :Oh<VW	
r&   c                   R\         P                  ^,          ,          pV P                  P                  RVR,           V,           4       V P	                  V P                  P
                  RV,           RV,           .4       R# )z;
IRCClient prefers to break long lines at word boundaries.
r2  r8   rd  r  Nr  r  s   & r   test_lineBreakOnWordBoundaries-ClientMsgTests.test_lineBreakOnWordBoundaries   s`     #00A56x#~89KK( :Oh<VW	
r&   c                8   V P                  \        \        P                  RR4       V P                  \        \        P                  R^ 4       V P	                  . \        P                  ! R^4      4       V P	                  . \        P                  ! R4      4       R# )z
L{twisted.words.protocols.irc.split} raises C{ValueError} if given a
length less than or equal to C{0} and returns C{[]} when splitting
C{''}.
r8   r*   N)r,   r  r   rO  r   r/   s   &r   test_splitSanityClientMsgTests.test_splitSanity-  sg     	*cii;*cii:SYYr1-.SYYr]+r&   c                    \         P                  ! R^4      pV P                  . ROV4       \         P                  ! R^4      pV P                  . ROV4       R# )z
L{twisted.words.protocols.irc.split} skips any delimiter (space or
newline) that it finds at the very beginning of the string segment it
is operating on.  Nothing should be added to the output list because of
it.
zxx yyzzxx
yyzN)xxyyz)r   rO  r   )r   rs   & r   test_splitDelimiters#ClientMsgTests.test_splitDelimiters9  sF     IIh"*A.IIi#*A.r&   c                    V P                  \        \        P                  R^ 4       V P                  \        \        P                  RR4       R# )zi
L{twisted.words.protocols.irc.split} raises C{ValueError} if given a
length less than or equal to C{0}.
r8   Nr&  )r,   r  r   rO  r/   s   &r   test_splitValidatesLength(ClientMsgTests.test_splitValidatesLengthE  s4    
 	*cii:*cii;r&   c                    V P                   P                  RR4       V P                  V P                   P                  R.4       R# )z
L{IRCClient.say} prepends the channel prefix C{"#"} if necessary and
then sends the message to the server for delivery to that channel.

thechannelzthe messagez PRIVMSG #thechannel :the messageN)r  sayr   r  r/   s   &r   test_sayClientMsgTests.test_sayM  s4    
 	m4**-O,PQr&   r  r  )"r   r   r    r!   rl   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r   r#  r'  r.  r1  r6  r"   r#   r$   s   @r   r  r    s     %BH



4 4 BABAVTVT3438	8	;






,
/<R Rr&   r  c                   ~   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tRtV tR# )ClientTestsiV  zg
Tests for the protocol-level behavior of IRCClient methods intended to
be called by application code.
c                   \        4       V n        \        4       V n        RV P                  n        V P                  P                  V P                  4       V P                  V P                  P                  4       R4       V P                  V P                  P                  4       V P                  V P                  P                  R4       R# )zD
Create and connect a new L{IRCClient} to a new L{StringTransport}.
Fr*   N)r   r  r	   r   r  r  r   r\  r  r  r  r/   s   &r   r  ClientTests.setUp\  s     )*!%*"$$T^^4 	##DNN$8$8$:B?55644d;r&   c                t    VP                  4       pVP                  R4      pVP                  R4      R,          # )z6
Return the last IRC message in the transport buffer.
r   rf  rz   )r\  r   rO  )r   r  r  s   && r   getLastLineClientTests.getLastLinel  s2      {{7#zz&!"%%r&   c                    RpV P                   P                  V4       RV 2R.pV P                  V P                  P	                  4       P                  R4      V4       R# )zE
L{IRCClient.away} sends an AWAY command with the specified message.
zSorry, I'm not here.AWAY :r*      
N)r   awayr   r  r\  rO  )r   rL  r!  s   &  r   	test_awayClientTests.test_awayt  sY     )7#WI
 	##DNN$8$8$:$@$@$I8Tr&   c                    V P                   P                  4        RR.pV P                  V P                  P	                  4       P                  R4      V4       R# )z@
L{IRCClient.back} sends an AWAY command with an empty message.
r@  r*   rA  N)r   backr   r  r\  rO  )r   r!  s   & r   	test_backClientTests.test_back  sK     	
 	##DNN$8$8$:$@$@$I8Tr&   c                    V P                   P                  R4       V P                  V P                  P	                  4       P                  R4      RR.4       R# )z+
L{IRCClient.whois} sends a WHOIS message.
alicerA  zWHOIS alicer*   Nr   r  r   r  r\  rO  r/   s   &r   
test_whoisClientTests.test_whois  sF     	G$##NN  "((1M23F	
r&   c                    V P                   P                  RR4       V P                  V P                  P	                  4       P                  R4      RR.4       R# )zo
L{IRCClient.whois} sends a WHOIS message with a server name if a
value is passed for the C{server} parameter.
rJ  zexample.orgrA  zWHOIS example.org alicer*   NrK  r/   s   &r   test_whoisWithServer ClientTests.test_whoisWithServer  sI    
 	G]3##NN  "((14Mr3R	
r&   c           	     X   RpRpRpRV P                   n        RV P                   n        V P                   P                  WV4       RV 2RV: RV: RV: R	V P                   P                  : 2R
.pV P	                  V P
                  P                  4       P                  R4      V4       R# )z}
L{IRCClient.register} sends NICK and USER commands with the
username, name, hostname, server name, and real name specified.
testusertesthost
testservertestnameNNICK USER rd  re  r*   rA  r   r  passwordregisterr   r  r\  rO  r   usernamer  rD  r!  s   &    r   test_registerClientTests.test_register  s    
 !
!+!%x:>H::t}}/E/EG	
 	##DNN$8$8$:$@$@$I8Tr&   c           
        RpRpRpRV P                   n        RV P                   n        V P                   P                  WV4       RV P                   P                   2RV 2RV: R	V: R	V: R
V P                   P                  : 2R.pV P	                  V P
                  P                  4       P                  R4      V4       R# )z
If the C{password} attribute of L{IRCClient} is not L{None}, the
C{register} method also sends a PASS command with it as the
argument.
rR  rS  rT  rU  testpasszPASS rV  rW  rd  re  r*   rA  NrX  r[  s   &    r   test_registerWithPassword%ClientTests.test_registerWithPassword  s     !
!+!+x:>DMM**+,H::t}}/E/EG
 	##DNN$8$8$:$@$@$I8Tr&   c                   RpRpRpRV P                   n        RV P                   n        V P                   P                  WV4       V P                   P	                  RR.4       V P                  V P                  4      pV P                  VRV 24       V P                   P	                  RR.4       V P                  V P                  4      pV P                  VR	P                  VR
,           4      4       R# )z
Verify that the client repeats the L{IRCClient.setNick} method with a
new value when presented with an C{ERR_NICKNAMEINUSE} while trying to
register.
rR  rS  rT  rU  r`  r   r   rV  NICK {}r*  N)
r   r  rY  rZ  irc_ERR_NICKNAMEINUSEr=  r  r   r   rZ  )r   r\  r  rD  lastLines   &    r   test_registerWithTakenNick&ClientTests.test_registerWithTakenNick  s     !
!+!+x:>++Hwi@##DNN3HhZ&89 	++Hwi@##DNN39#3#3HtO#DEr&   c                $   RpR V P                   n        V P                   P                  V4       V P                   P                  RR.4       V P	                  V P
                  4      pV P                  VRP                  VR,           4      4       R# )z
L{IRCClient.alterCollidedNick} determines how a nickname is altered upon
collision while a user is trying to change to that nickname.
r8   c                     V R ,           # )***r   rQ  s   &r   r  <ClientTests.test_overrideAlterCollidedNick.<locals>.<lambda>  s    te|r&   r   r   rd  rk  N)r   alterCollidedNickrZ  re  r=  r  r   rZ  )r   rR  rf  s   &  r   test_overrideAlterCollidedNick*ClientTests.test_overrideAlterCollidedNick  sp    
 *C't$++Hwi@##DNN39#3#3D5L#ABr&   c                   RpRpV P                   P                  V4       V P                   P                  RR.4       V P                   P                  V4       V P	                  V P                   P
                  V4       V P                   P                  V R2V.4       V P	                  V P                   P
                  V4       R# )z
When a NICK command is sent after signon, C{IRCClient.nickname} is set
to the new nickname I{after} the server sends an acknowledgement.
r8   r  r   r   z	!quux@quxN)r   rZ  r
  setNickr   rb  irc_NICK)r   oldnicknewnicks   &  r   test_nickChangeClientTests.test_nickChange  s    
 w'%%h	:g&//9')4wi@//9r&   c                   RpV P                  V P                  P                  R4       V P                  P                  V4       V P                  P	                  RR.4       V P                  V P                  4      pV P                  VRV P                  P                   24       V P                  P                  RR.4       V P                  V P                  P                  R4       V P                  P                  V P                  P                  4       V P                  V P                  P                  V P                  P                  4       V P                  P                  pV P                  P                  V4       V P                  P	                  RR.4       V P                  V P                  4      pV P                  VRV 24       V P                  V P                  P                  V4       R# )z
Trying to register an illegal nickname results in the default legal
nickname being set, and trying to change a nickname to an illegal
nickname results in the old nickname being kept.
r8   Fr   r   rV  TN)r   r   _registeredrZ  irc_ERR_ERRONEUSNICKNAMEr=  r  erroneousNickFallbackr
  rq  rb  )r   badnickrf  rs  s   &   r   test_erroneousNickClientTests.test_erroneousNick  so    22E:w'..x'C##DNN3U4==+N+N*O#PQ%%h	:22D9dmmAAB//1T1TU --((g&..x'C##DNN3U7)#45//9r&   c                   RpRpRpV P                   P                  W4       V P                   P                  W#4       RV RV R2RV RV R2R.pV P                  V P                  P	                  4       P                  R4      V4       R	# )
zL
L{IRCClient.desrcibe} sends a CTCP ACTION message to the target
specified.
r8   r  waveszPRIVMSG z
 :ACTION r*   rA  N)r   describer   r  r\  rO  )r   r  r  r   r!  s   &    r   test_describeClientTests.test_describe	  s    
 v.w/vhl6(#6wi|F837

 	##DNN$8$8$:$@$@$I8Tr&   c                r   a  V 3R lpVS P                   n        S P                   P                  RRR.4       R# )zP
The default implementation of L{IRCClient.noticed} doesn't invoke
C{privmsg()}
c                 *   < SP                  R 4       R# )z%privmsg() should not have been calledN)fail)r  r  rL  r   s   &&&r   r  6ClientTests.test_noticedDoesntPrivmsg.<locals>.privmsg'	  s    II=>r&   spamz#greasyspooncafezI don't want any spam!N)r   r  
irc_NOTICE)r   r  s   f r   test_noticedDoesntPrivmsg%ClientTests.test_noticedDoesntPrivmsg!	  s1    	? !(  *<>V)WXr&   c                >   V P                   P                  R4       V P                  V P                  P	                  4       P                  R4      4       V P                  P                  4        V P                   P                  RR4       V P                  V P                  P	                  4       R4       V P                  P                  4        / V P                   n        \        V P                   P                  ^,           4       FA  p\        P                  ! 4       V,           V P                   P                  R\        V4      3&   KC  	  V P                  \        V P                   P                  4      V P                   P                  ^,           4       V P                   P                  RR4       V P                  \        V P                   P                  4      V P                   P                  4       V P                  V P                  P	                  4       R4       R# )z
L{IRCClient.ping}
	otherusers   PRIVMSG otheruser :PINGzare you theres)   PRIVMSG otheruser :PING are you there
zI sent a lot of pingss1   PRIVMSG otheruser :PING I sent a lot of pings
N)r   pingrS  r  r\  r,  clearr   _pingsrange_MAX_PINGRINGr  r   r7  )r   pingNums   & r   	test_pingClientTests.test_ping-	  s~   
 	;'NN  "--.LM	
 	 	;8NN  "$X	
 	  "T]]881<=GBF))+PWBWDMM  +W!>? >T]]112DMM4O4ORS4ST 	;(?@T]]112DMM4O4OPNN  "H	
r&   )r   r  N)r   r   r    r!   rl   r  r=  rC  rG  rL  rO  r]  ra  rg  rn  ru  r|  r  r  r  r"   r#   r$   s   @r   r9  r9  V  sb     
< &
U	U

U&U*F*
C::6U"
Y
 
r&   r9  c                   *   a  ] tR tRt o RtR tRtV tR# )CollectorClientiO	  zI
A client that saves in a list the names of the methods that got called.
c                j   a  . S n         RS n        V F  pV3V 3R llp\        S W#! 4       4       K  	  R# )z`
@param methodsList: list of methods' names that should be replaced.
@type methodsList: C{list}
Wolfc                   <a  V V3R lpV# )z
Collects C{method}s.
c                  B   < SP                   P                  SV 34       R # r  )r+  r:  )r  r<  r   s   *r   inner<CollectorClient.__init__.<locals>.fake_method.<locals>.innerc	  s    LL''7r&   r   )r<  r  r   s   f r   fake_method-CollectorClient.__init__.<locals>.fake_method^	  s    
8 r&   N)r+  rb  setattr)r   methodsListr<  r  s   f&  r   r'  CollectorClient.__init__T	  s5    
 !F#)  D&+-0 "r&   )r+  rb  N)r   r   r    r!   rl   r'  r"   r#   r$   s   @r   r  r  O	  s     1 1r&   r  c                   r   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tRtV tR# )DccTestsik	  z
Tests for C{dcc_*} methods.
c                J    . ROpRV n         RV n        \        V4      V n        R# )	dccDoSendr  #twistedN)r  dccDoAcceptResumedccDoResume	dccDoChatr  r  r  r  r   r+  s   & r   r  DccTests.setUpp	  s!    P+	!%g.r&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RV P                  RRRR. RO33.4       R# )	z?
L{irc.IRCClient.dcc_SEND} invokes L{irc.IRCClient.dccDoSend}.
foo.txt 127.0.0.1 1025r  	127.0.0.1  foo.txtNr&  r  r  1025)r  dcc_SENDr  r  r   r+  r/   s   &r   test_dccSendDccTests.test_dccSendv	  sh     	TYY6NOKK  		#!8
	
r&   c                t    \         P                  ! 4       pV P                  \        VP                  RR4       R# )z=
L{irc.IRCClient.dccDoSend} is raises C{NotImplementedError}
r\  N)r   r	   r,   NotImplementedErrordccSend)r   r  s   & r   test_dccSendNotImplemented#DccTests.test_dccSendNotImplemented	  s(     -v~~z4Pr&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )zc
L{irc.IRCClient.dcc_SEND} raises L{irc.IRCBadMessage} when it is passed
a malformed query string.
r8   z#malformed DCC SEND request: ['foo']N	r,   r   IRCBadMessager  r  r  r  r   r   r   r  s   & r   test_dccSendMalformedRequest%DccTests.test_dccSendMalformedRequest	  N    
 ""t{{33TYYe
 	V&KLr&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )z~
L{irc.IRCClient.dcc_SEND} raises L{irc.IRCBadMessage} when it is passed
a query string that doesn't contain a valid address.
zfoo.txt #23 sd@dzIndecipherable address '#23'Nr  r  s   & r   !test_dccSendIndecipherableAddress*DccTests.test_dccSendIndecipherableAddress	  sR    
 ""KK  IILL
 	V&DEr&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )z
L{irc.IRCClient.dcc_SEND} raises L{irc.IRCBadMessage} when it is passed
a query string that doesn't contain a valid port number.
foo.txt 127.0.0.1 sd@dIndecipherable port 'sd@d'Nr  r  s   & r   test_dccSendIndecipherablePort'DccTests.test_dccSendIndecipherablePort	  R    
 ""KK  IILL$
 	V&BCr&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RV P                  RR^33.4       R# )zI
L{irc.IRCClient.dcc_ACCEPT} invokes L{irc.IRCClient.dccDoAcceptResume}.
foo.txt 1025 2r  r  r  N)r  
dcc_ACCEPTr  r  r   r+  r/   s   &r   test_dccAcceptDccTests.test_dccAccept	  sV     	tyy$,,8HIKK!DIIy$#BCD	
r&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )ze
L{irc.IRCClient.dcc_ACCEPT} raises L{irc.IRCBadMessage} when it is
passed a malformed query string.
r8   z*malformed DCC SEND ACCEPT request: ['foo']N)	r,   r   r  r  r  r  r  r   r   r  s   & r   test_dccAcceptMalformedRequest'DccTests.test_dccAcceptMalformedRequest	  O    
 ""t{{55tyy$,,PU
 	V&RSr&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RV P                  RR^33.4       R# )zC
L{irc.IRCClient.dcc_RESUME} invokes L{irc.IRCClient.dccDoResume}.
r  r  r  r  N)r  
dcc_RESUMEr  r  r   r+  r/   s   &r   test_dccResumeDccTests.test_dccResume	  sU     	tyy$,,8HIKK=499iq2Q"R!S	
r&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )ze
L{irc.IRCClient.dcc_RESUME} raises L{irc.IRCBadMessage} when it is
passed a malformed query string.
r8   z*malformed DCC SEND RESUME request: ['foo']N)	r,   r   r  r  r  r  r  r   r   r  s   & r   test_dccResumeMalformedRequest'DccTests.test_dccResumeMalformedRequest	  r  r&   c           
         V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RV P                  V P                  RR. RO33.4       R# )z?
L{irc.IRCClient.dcc_CHAT} invokes L{irc.IRCClient.dccDoChat}.
r  r  r  r  Nr  )r  dcc_CHATr  r  r   r+  r/   s   &r   test_dccChatDccTests.test_dccChat	  si     	TYY6NOKK  		#8		
r&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )zc
L{irc.IRCClient.dcc_CHAT} raises L{irc.IRCBadMessage} when it is
passed a malformed query string.
r8   z#malformed DCC CHAT request: ['foo']N	r,   r   r  r  r  r  r  r   r   r  s   & r   test_dccChatMalformedRequest%DccTests.test_dccChatMalformedRequest	  r  r&   c                    V P                  \        P                  V P                  P                  V P
                  V P                  R4      pV P                  \        V4      R4       R# )z
L{irc.IRCClient.dcc_CHAT} raises L{irc.IRCBadMessage} when it is passed
a query string that doesn't contain a valid port number.
r  r  Nr  r  s   & r   test_dccChatIndecipherablePort'DccTests.test_dccChatIndecipherablePort	  r  r&   r  r  r  N)r   r   r    r!   rl   r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r#   r$   s   @r   r  r  k	  sY     /
,QMFD
T
T
*MD Dr&   r  c                   Z   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )ServerToClientTestsi
  zD
Tests for the C{irc_*} methods sent from the server to the client.
c                J    R V n         RV n        . ROp\        V4      V n        R# )r  r  N)	r  r  r  r  userQuitr  r  r  r!  r  r  s   & r   r  ServerToClientTests.setUp
  s%    +	!

 &g.r&   c                   V P                   P                  V P                  V P                  .4       V P                   P                  RR.4       V P	                  V P                   P
                  RV P                  33R.4       R# )zq
L{IRCClient.joined} is called when I join a channel;
L{IRCClient.userJoined} is called when someone else joins.
Svadilfari!~svadi@yok.utu.fi#pythonr  N)r  
Svadilfarir  )r  irc_JOINr  r  r   r+  r/   s   &r   test_irc_JOIN!ServerToClientTests.test_irc_JOIN#
  sh    
 	TYY7;i[IKK(*ST	
r&   c                   V P                   P                  V P                  V P                  .4       V P                   P                  RR.4       V P	                  V P                   P
                  RV P                  33R.4       R# )zo
L{IRCClient.left} is called when I part the channel;
L{IRCClient.userLeft} is called when someone else parts.
r  r  r  N)r  r  )r  irc_PARTr  r  r   r+  r/   s   &r   test_irc_PART!ServerToClientTests.test_irc_PART/
  sh    
 	TYY7;i[IKKt||o&(OP	
r&   c                    V P                   P                  RR.4       V P                   P                  V P                  R.4       V P                  V P                   P                  RR.4       R# )zW
L{IRCClient.userQuit} is called whenever someone quits
the channel (myself included).
r  Adios.	Farewell.N)r  )r  r  )r  )r  r  )r  irc_QUITr  r   r+  r/   s   &r   test_irc_QUIT!ServerToClientTests.test_irc_QUIT;
  s[    
 	;hZHTYY6KK63	
r&   c                R   RR\         P                  R\         P                  \         P                  ,           /,          pV P                  P                  V P                  V P                  V.4       V P                  V P                  P                  RV P                  RR33.4       R# )z;
L{IRCClient.noticed} is called when a notice is received.
z:%(X)cextended%(X)cdata1%(X)cextended%(X)cdata2%(X)c%(EOL)sr   r  r  r  zdata1 data2N)
r   r  r   r  r  r  r  r  r   r+  rp  s   & r   test_irc_NOTICE#ServerToClientTests.test_irc_NOTICEJ
  s     K366CFF?N
 
 	tyy4<<*=>KK9tyy*m.T"U!V	
r&   c           	        V P                   P                  R. RO4       V P                   P                  V P                  V P                  RR.4       V P	                  V P                   P
                  RRRV P                  RR33.4       R# )	z
L{IRCClient.kickedFrom} is called when I get kicked from the channel;
L{IRCClient.userKicked} is called when someone else gets kicked.
r  r  z	hadouken!r  r  N)r  WOLF
shoryuken!)r  )r  r  r  )r  irc_KICKr  r  r   r+  r/   s   &r   test_irc_KICK!ServerToClientTests.test_irc_KICKW
  sy     	*,M	
 	TYY|[(QRKKGdllFKPQ	
r&   c                    V P                   P                  V P                  V P                  R.4       V P	                  V P                   P
                  RRV P                  R33.4       R# )zB
L{IRCClient.topicUpdated} is called when someone sets the topic.
new topic is newr!  r  N)r  	irc_TOPICr  r  r   r+  r/   s   &r   test_irc_TOPIC"ServerToClientTests.test_irc_TOPICi
  sX     	dii$,,8J)KLKKvt||5GHIJ	
r&   c                    V P                   P                  V P                  RV P                  R.4       V P	                  V P                   P
                  RRV P                  R33.4       R# )zK
L{IRCClient.topicUpdated} is called when the topic is initially
reported.
?r
  r!  r  N)r  irc_RPL_TOPICr  r  r   r+  r/   s   &r   test_irc_RPL_TOPIC&ServerToClientTests.test_irc_RPL_TOPICs
  sZ    
 	!!$))c4<<AS-TUKKvt||5GHIJ	
r&   c                    V P                   P                  V P                  RV P                  .4       V P	                  V P                   P
                  RRV P                  R33.4       R# )z@
L{IRCClient.topicUpdated} is called when the topic is removed.
r  r!  r  r*   N)r  irc_RPL_NOTOPICr  r  r   r+  r/   s   &r   test_irc_RPL_NOTOPIC(ServerToClientTests.test_irc_RPL_NOTOPIC~
  sU     	##DIIT\\/BCKK>FDLL"3M"N!O	
r&   r  N)r   r   r    r!   rl   r  r  r  r  r  r  r  r  r  r"   r#   r$   s   @r   r  r  
  s<     / 






$
	

 
r&   r  c                   T   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tRtV tR# )CTCPQueryTestsi
  z'
Tests for the C{ctcpQuery_*} methods.
c                D    R V n         RV n        \        R.4      V n        R# )r  r  ctcpMakeReplyNr  r/   s   &r   r  CTCPQueryTests.setUp
  s    +	!%&78r&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RRR.33.4       R# )zU
L{IRCClient.ctcpQuery_PING} calls L{IRCClient.ctcpMakeReply} with the
correct args.
r  r  r  N)PINGr  )r  ctcpQuery_PINGr  r  r   r+  r/   s   &r   test_ctcpQuery_PING"CTCPQueryTests.test_ctcpQuery_PING
  sP    
 	""499dllFCKK?V>N=O4P"Q!R	
r&   c                    RV P                   n        V P                   P                  V P                  V P                  R4       V P                  V P                   P                  RRR.33.4       R# )zW
L{IRCClient.ctcpQuery_FINGER} calls L{IRCClient.ctcpMakeReply} with the
correct args.
r  r  r  r  N)FINGERr  )r  fingerReplyctcpQuery_FINGERr  r  r   r+  r/   s   &r   test_ctcpQuery_FINGER$CTCPQueryTests.test_ctcpQuery_FINGER
  s\    
 #*$$TYYfEKK?V>Q=R4S"T!U	
r&   c                    RV P                   n        V P                   P                  V P                  V P                  R4       V P                  V P                   P                  RRRR.33.4       R# )zW
L{IRCClient.ctcpQuery_SOURCE} calls L{IRCClient.ctcpMakeReply} with the
correct args.
urlr  r  r  N)SOURCEr(  )r)  N)r  	sourceURLctcpQuery_SOURCEr  r  r   r+  r/   s   &r   test_ctcpQuery_SOURCE$CTCPQueryTests.test_ctcpQuery_SOURCE
  s`    
 !&$$TYYfEKK):<L(MNOP	
r&   c                    RV P                   n        V P                   P                  V P                  V P                  R4       V P                  V P                   P                  RRR.33.4       R# )zY
L{IRCClient.ctcpQuery_USERINFO} calls L{IRCClient.ctcpMakeReply} with
the correct args.
rB  r  r  r  N)USERINFOrB  )r  userinfoctcpQuery_USERINFOr  r  r   r+  r/   s   &r   test_ctcpQuery_USERINFO&CTCPQueryTests.test_ctcpQuery_USERINFO
  s\    
  &&&tyy$,,GKK?V>R=S4T"U!V	
r&   c                6   V P                   P                  V P                  V P                  R4       V P                   P                  V P                  V P                  R4       RpV P	                  V P                   P
                  RRRV3.33RRR.33.4       R# )	z[
L{IRCClient.ctcpQuery_CLIENTINFO} calls L{IRCClient.ctcpMakeReply} with
the correct args.
r*   z	PING PONGzEACTION CLIENTINFO DCC ERRMSG FINGER PING SOURCE TIME USERINFO VERSIONr  r  
CLIENTINFON)r5  N)r  ctcpQuery_CLIENTINFOr  r  r   r+  )r   rB  s   & r   test_ctcpQuery_CLIENTINFO(CTCPQueryTests.test_ctcpQuery_CLIENTINFO
  s    
 	((DLL"E((DLL+NV 	 	KK 6\4,@+A"BC 6,@+A"BC	
r&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  ^ ,          ^,          ^ ,          R4       R# )zU
L{IRCClient.ctcpQuery_TIME} calls L{IRCClient.ctcpMakeReply} with the
correct args.
r  r  N)r  ctcpQuery_TIMEr  r  r   r+  r/   s   &r   test_ctcpQuery_TIME"CTCPQueryTests.test_ctcpQuery_TIME
  sK    
 	""499dllFC,,Q/215v>r&   c                    V P                   P                  V P                  V P                  R4       V P	                  V P                   P
                  RRR.33.4       R# )zT
L{IRCClient.ctcpQuery_DCC} calls L{IRCClient.ctcpMakeReply} with the
correct args.
r  r  r  N)ERRMSGz!DCC data :Unknown DCC type 'DATA')r  ctcpQuery_DCCr  r  r   r+  r/   s   &r   test_ctcpQuery_DCC!CTCPQueryTests.test_ctcpQuery_DCC
  sX    
 	!!$))T\\6BKK $MNO	
r&   r  N)r   r   r    r!   rl   r  r  r%  r,  r2  r7  r;  r@  r"   r#   r$   s   @r   r  r  
  s7     9

	


	

$?
 
r&   r  c                   *   a  ] tR tRt o RtR tRtV tR# )DccChatFactoryTestsi
  z
Tests for L{DccChatFactory}.
c                    Rp\         P                  ! RV4      pVP                  R4      pV P                  V\         P                  4       V P                  VP                  V4       R# )z}
An instance of the L{irc.DccChat} protocol is returned, which has the
factory property set to the factory which created it.
Nr  )fromUserNN)r   DccChatFactorybuildProtocolassertIsInstanceDccChatr   factory)r   	queryDatarJ  r   s   &   r   test_buildProtocol&DccChatFactoryTests.test_buildProtocol
  sU    
 -	$$T95((5h4))73r&   r   N)r   r   r    r!   rl   rL  r"   r#   r$   s   @r   rC  rC  
  s     	4 	4r&   rC  c                   *   a  ] tR tRt o RtR tRtV tR# )DccDescribeTestsi
  z
Tests for L{dccDescribe}.
c                V    \         P                  ! R4      pV P                  VR4       R# )z0
L{irc.dccDescribe} supports long IP addresses.
zCHAT arg 3232235522 6666z$CHAT for host 192.168.0.2, port 6666N)r   dccDescriber   r  s   & r   test_addressDccDescribeTests.test_address
  s$     !;<!GHr&   r   N)r   r   r    r!   rl   rR  r"   r#   r$   s   @r   rO  rO  
  s     I Ir&   rO  c                   ^   a  ] tR tRt o RtRR ltR tR tR tR t	R	 t
R
 tR tR tRtV tR# )DccFileReceiveTestsi  z
Tests for L{DccFileReceive}.
Nc                    \         P                  ! WR7      pV'       d   VP                  ! R4       \        4       pVP                  ! V4       V# )a<  
Factory helper that returns a L{DccFileReceive} instance
for a specific test case.

@param filename: Path to the local file where received data is stored.
@type filename: L{str}

@param resumeOffset: An integer representing the amount of bytes from
    where the transfer of data should be resumed.
@type resumeOffset: L{int}

@param overwrite: A boolean specifying whether the file to write to
    should be overwritten by calling L{DccFileReceive.set_overwrite}
    or not.
@type overwrite: L{bool}

@return: An instance of L{DccFileReceive}.
@rtype: L{DccFileReceive}
resumeOffsetT)r   DccFileReceiveset_overwriter   r  )r   filenamerX  	overwriter   r  s   &&&&  r   makeConnectedDccFileReceive/DccFileReceiveTests.makeConnectedDccFileReceive  s@    ( %%hJ""4(#%		*r&   c                N    VP                   ! V4       VP                  ! R4       R# )z
Arrange the protocol so that it received all data.

@param protocol: The protocol which will receive the data.
@type: L{DccFileReceive}

@param data: The received data.
@type data: L{bytest}
N)r  r  )r   r   r  s   &&&r   allDataReceivedForProtocol.DccFileReceiveTests.allDataReceivedForProtocol'  s      	d#%r&   c                    \        V P                  4       4      pVP                  R4       V P                  VP                  ^R7      pV P                  VR4       V P                  VP                  4       R4       R# )zz
If given a resumeOffset argument, L{DccFileReceive} will attempt to
resume from that number of bytes if the file exists.
s   Twisted is awesome!rW  s   amazing!   Twisted is amazing!Nr   mktemp
setContentr]  pathr`  r   
getContentr   fpr   s   &  r   test_resumeFromResumeOffset/DccFileReceiveTests.test_resumeFromResumeOffset4  sa    
 dkkm$
,-33BGG"3M''+>*@Ar&   c                    \        V P                  4       4      pVP                  R4       V P                  VP                  ^R7      pV P                  VR4       V P                  VP                  4       R4       R# )a  
When resuming from an offset somewhere in the middle of the file,
for example, if there are 50 bytes in a file, and L{DccFileReceive}
is given a resumeOffset of 25, and after that 15 more bytes are
written to the file, then the resultant file should have just 40
bytes of data.
rc  rW  s   cool!s   Twisted is cool!Nrd  ri  s   &  r   :test_resumeFromResumeOffsetInTheMiddleOfAlreadyWrittenDataNDccFileReceiveTests.test_resumeFromResumeOffsetInTheMiddleOfAlreadyWrittenDataA  sa     dkkm$
,-33BGG"3M''(;*=>r&   c                    \        V P                  4       4      pVP                  R4       V P                  VP                  RR7      pV P                  VR4       V P                  VP                  4       R4       R# )zh
When local file already exists it can be overwritten using the
L{DccFileReceive.set_overwrite} method.
s   I love contributing to Twisted!T)r\  s   Twisted rocks!Nrd  ri  s   &  r   test_setOverwrite%DccFileReceiveTests.test_setOverwriteQ  sb    
 dkkm$
8933BGGt3L''2CD*;<r&   c                    \        V P                  4       4      pV P                  VP                  4      pV P	                  VR4       V P                  VP                  4       R4       R# )zf
If the file does not already exist, then L{DccFileReceive} will
create one and write the data to it.
s   I <3 TwistedN)r   re  r]  rg  r`  r   rh  ri  s   &  r   test_fileDoesNotExist)DccFileReceiveTests.test_fileDoesNotExist^  sN    
 dkkm$33BGG<''/B/:r&   c                    \        V P                  4       4      pV P                  \        V P                  VP
                  ^R7      pV P                  \        P                  VP                  4       R# )zs
If given a resumeOffset to resume writing to a file that does not
exist, L{DccFileReceive} will raise L{OSError}.
rW  N)	r   re  r,   OSErrorr]  rg  r   errnoENOENT)r   rj  r3  s   &  r   test_resumeWhenFileDoesNotExist3DccFileReceiveTests.test_resumeWhenFileDoesNotExistj  sV    
 dkkm$!!T55rwwQ " 
 	u{{3r&   c                    \        V P                  4       4      pVP                  4        V P                  \        V P
                  VP                  4       R# )zV
If the file already exists and overwrite action was not asked,
L{OSError} is raised.
N)r   re  touchr,   rw  r]  rg  r   rj  s   & r   !test_fileAlreadyExistsNoOverwrite5DccFileReceiveTests.test_fileAlreadyExistsNoOverwritew  s9    
 dkkm$

'4#C#CRWWMr&   c                    \        V P                  4       4      P                  R4      pV P                  \        V P
                  VP                  4       R# )z?
L{IOError} is raised when failing to open the requested path.
zchild-with-no-existing-parentN)r   re  childr,   IOErrorr]  rg  r~  s   & r   test_failToOpenLocalFile,DccFileReceiveTests.test_failToOpenLocalFile  s<     dkkm$**+JK'4#C#CRWWMr&   r   )rq   N)r   r   r    r!   rl   r]  r`  rk  rn  rq  rt  rz  r  r  r"   r#   r$   s   @r   rU  rU    s@     6&B? =
;4NN Nr&   rU  )6rl   rx  r|   r  twisted.internetr   r   twisted.internet.testingr   r   twisted.python.filepathr   twisted.trial.unittestr   twisted.words.protocolsr   twisted.words.protocols.ircr	   r
   r   r   r(   rn   r   r   rZ  r   r   r   X_QUOTEM_QUOTEr   r   _CommandDispatcherMixinr   r   r  r  r  r	  rZ  r\  r  r  r  r  r9  r  r  r  r  rC  rO  rU  r   r&   r   <module>r     s      + L , + ' B+( +*M&{ M&`
 
,\
 \
~"
K "
L :'..377.;(//366cff/E2
CKKckk*+	C; C ,, (Fk FD_;+ _;DCMM z) z)zE* EPH; H;VBK BJ1#-- 18A A8tR[ tRn	v
+ v
r1cmm 18`D{ `DFw
+ w
t^
[ ^
B4+ 4"
I{ 
I@N+ @Nr&   