+
    Dfjb                         R t ^ RIHtHtHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHtHtHtHt ^ RIHt  ! R R4      t ! R	 R
]]4      t ! R R]]4      tR# )z$
Test the memcache client protocol.
)DeferredDeferredListTimeoutErrorgatherResults)ConnectionDone)Clock) StringTransportWithDisconnection)ClientErrorMemCacheProtocolNoSuchCommandServerError)TestCasec                      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R tRtV tR# )CommandMixinzG
Setup and tests for basic invocation of L{MemCacheProtocol} commands.
c                    \        4       h)zX
Helper test method to test the resulting C{Deferred} of a
L{MemCacheProtocol} command.
)NotImplementedErrorselfdsendrecvresults   &&&&&</usr/lib/python3/dist-packages/twisted/test/test_memcache.py_testCommandMixin._test   s    
 "##    c                \    V P                  V P                  P                  R4      RRR4      # )z
L{MemCacheProtocol.get} returns a L{Deferred} which is called back with
the value and the flag associated with the given key if the server
returns a successful result.
   foo	   get foo
   VALUE foo 0 3
bar
END
       barr   protogetr   s   &r   test_getCommandMixin.test_get"   s.     zzJJNN6".	
 	
r   c                \    V P                  V P                  P                  R4      RRR4      # )z]
Test getting a non-available key: it succeeds but return L{None} as
value and C{0} as flag.
r   r      END
r!   Nr#   r&   s   &r   test_emptyGetCommandMixin.test_emptyGet/   s&    
 zz$**..0.*iXXr   c           	     h    V P                  V P                  P                  RR.4      RRRRRR/4      # )z
L{MemCacheProtocol.getMultiple} returns a L{Deferred} which is called
back with a dictionary of flag, value for each given key.
r      cow   get foo cow
s1   VALUE foo 0 3
bar
VALUE cow 0 7
chicken
END
)r!   s   chickenr    r   r$   getMultipler&   s   &r   test_getMultipleCommandMixin.test_getMultiple6   s>    
 zzJJ""FF#34J_fk:	
 	
r   c           	     h    V P                  V P                  P                  RR.4      RRRRRR/4      # )zq
When L{MemCacheProtocol.getMultiple} is called with non-available keys,
the corresponding tuples are (0, None).
r   r/   r0   s   VALUE cow 1 3
bar
END
)   r"   r+   r1   r&   s   &r   test_getMultipleWithEmpty&CommandMixin.test_getMultipleWithEmptyB   s>    
 zzJJ""FF#34.[&)4	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )zn
L{MemCacheProtocol.set} returns a L{Deferred} which is called back with
C{True} when the operation succeeds.
r   r"   s   set foo 0 0 3
bar
   STORED
T)r   r$   setr&   s   &r   test_setCommandMixin.test_setN   0    
 zzJJNN66*'	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )zn
L{MemCacheProtocol.add} returns a L{Deferred} which is called back with
C{True} when the operation succeeds.
r   r"      add foo 0 0 3
bar
r:   Tr   r$   addr&   s   &r   test_addCommandMixin.test_addZ   r>   r   c                ^    V P                  V P                  P                  RR4      RRR4      # )zr
L{MemCacheProtocol.replace} returns a L{Deferred} which is called back
with C{True} when the operation succeeds.
r   r"      replace foo 0 0 3
bar
r:   Tr   r$   replacer&   s   &r   test_replaceCommandMixin.test_replacef   s2    
 zzJJvv.+	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z
Test an erroneous add: if a L{MemCacheProtocol.add} is called but the
key already exists on the server, it returns a B{NOT STORED} answer,
which calls back the resulting L{Deferred} with C{False}.
r   r"   r@      NOT STORED
FrA   r&   s   &r   test_errorAddCommandMixin.test_errorAddr   s0     zzJJNN66*'	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z
Test an erroneous replace: if a L{MemCacheProtocol.replace} is called
but the key doesn't exist on the server, it returns a B{NOT STORED}
answer, which calls back the resulting L{Deferred} with C{False}.
r   r"   rF   rL   FrG   r&   s   &r   test_errorReplaceCommandMixin.test_errorReplace   s2     zzJJvv.+	
 	
r   c                \    V P                  V P                  P                  R4      RRR4      # )zx
L{MemCacheProtocol.delete} returns a L{Deferred} which is called back
with C{True} when the server notifies a success.
r"      delete bar
s	   DELETED
Tr   r$   deleter&   s   &r   test_deleteCommandMixin.test_delete   s.    
 zzJJf%'8.$
 	
r   c                \    V P                  V P                  P                  R4      RRR4      # )z
Test an error during a delete: if key doesn't exist on the server, it
returns a B{NOT FOUND} answer which calls back the resulting
L{Deferred} with C{False}.
r"   rS   s   NOT FOUND
FrT   r&   s   &r   test_errorDeleteCommandMixin.test_errorDelete   s/     zzJJf%'8:JE
 	
r   c                \    V P                  V P                  P                  R4      RR^4      # )z
Test incrementing a variable: L{MemCacheProtocol.increment} returns a
L{Deferred} which is called back with the incremented value of the
given key.
r   s   incr foo 1
   4
r   r$   	incrementr&   s   &r   test_incrementCommandMixin.test_increment   *     zz$**..v68I8UVWWr   c                \    V P                  V P                  P                  R4      RR^4      # )z
Test decrementing a variable: L{MemCacheProtocol.decrement} returns a
L{Deferred} which is called back with the decremented value of the
given key.
r   s   decr foo 1
   5
r   r$   	decrementr&   s   &r   test_decrementCommandMixin.test_decrement   ra   r   c                ^    V P                  V P                  P                  R^4      RR^4      # )zy
L{MemCacheProtocol.increment} takes an optional argument C{value} which
replaces the default value of 1 when specified.
r   s   incr foo 8
r\   r]   r&   s   &r   test_incrementValCommandMixin.test_incrementVal   0    
 zzJJ  +->!
 	
r   c                ^    V P                  V P                  P                  R^4      RR^4      # )zy
L{MemCacheProtocol.decrement} takes an optional argument C{value} which
replaces the default value of 1 when specified.
r   s   decr foo 3
rc   rd   r&   s   &r   test_decrementValCommandMixin.test_decrementVal   rk   r   c           	     b    V P                  V P                  P                  4       RRRRRR/4      # )z
Test retrieving server statistics via the L{MemCacheProtocol.stats}
command: it parses the data sent by the server and calls back the
resulting L{Deferred} with a dictionary of the received statistics.
s   stats
"   STAT foo bar
STAT egg spam
END
r   r"      egg   spamr   r$   statsr&   s   &r   
test_statsCommandMixin.test_stats   s7     zzJJ7VVW-	
 	
r   c           	     d    V P                  V P                  P                  R4      RRRRRR/4      # )a  
L{MemCacheProtocol.stats} takes an optional C{bytes} argument which,
if specified, is sent along with the I{STAT} command.  The I{STAT}
responses from the server are parsed as key/value pairs and returned
as a C{dict} (as in the case where the argument is not specified).
s   blahs   stats blah
rp   r   r"   rq   rr   rs   r&   s   &r   test_statsWithArgument#CommandMixin.test_statsWithArgument   s9     zzJJW%7VVW-	
 	
r   c                Z    V P                  V P                  P                  4       RRR4      # )z
Test version retrieval via the L{MemCacheProtocol.version} command: it
returns a L{Deferred} which is called back with the version sent by the
server.
s	   version
s   VERSION 1.1
s   1.1)r   r$   versionr&   s   &r   test_versionCommandMixin.test_version   s,     zzJJ .2Df
 	
r   c                Z    V P                  V P                  P                  4       RRR4      # )zz
L{MemCacheProtocol.flushAll} returns a L{Deferred} which is called back
with C{True} if the server acknowledges success.
s   flush_all
s   OK
T)r   r$   flushAllr&   s   &r   test_flushAllCommandMixin.test_flushAll   s'    
 zz$**--/1A9dSSr    N)__name__
__module____qualname____firstlineno____doc__r   r'   r,   r3   r7   r<   rC   rI   rM   rP   rV   rY   r_   rf   ri   rm   ru   rx   r|   r   __static_attributes____classdictcell____classdict__s   @r   r   r      sx     $
Y













XX




T Tr   r   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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!# )"MemCacheTestsz1
Test client protocol class L{MemCacheProtocol}.
c                *   \        4       V n        \        4       V n        V P                  P                  V P                  n        \        4       V n        V P                  V P                  n        V P                  P                  V P                  4       R# )zc
Create a memcache client, connect it to a string protocol, and make it
use a deterministic clock.
N)	r
   r$   r   clock	callLaterr   	transportprotocolmakeConnectionr&   s   &r   setUpMemCacheTests.setUp   s]    
 &'
W
#zz33

9;"&**

!!$..1r   c                   a a VV 3R lpS P                  S P                  P                  4       V4       VP                  V4       S P                  P                  V4       V# )a  
Implementation of C{_test} which checks that the command sends C{send}
data, and that upon reception of C{recv} the result is C{result}.

@param d: the resulting deferred from the memcache command.
@type d: C{Deferred}

@param send: the expected data to be sent.
@type send: C{bytes}

@param recv: the data to simulate as reception.
@type recv: C{bytes}

@param result: the expected result.
@type result: C{any}
c                 ,   < SP                  V S4       R # N)assertEqual)resr   r   s   &r   cbMemCacheTests._test.<locals>.cb  s    S&)r   )r   r   valueaddCallbackr$   dataReceived)r   r   r   r   r   r   s   f&&&f r   r   MemCacheTests._test   sJ    $	* 	--/6	b

%r   c                    V P                   P                  R4       V P                  \        V P                   P                  R4       R# )z
If the value returned doesn't match the expected key of the current
C{get} command, an error is raised in L{MemCacheProtocol.dataReceived}.
r   s   VALUE bar 0 7
spamegg
END
N)r$   r%   assertRaisesRuntimeErrorr   r&   s   &r   test_invalidGetResponse%MemCacheTests.test_invalidGetResponse  s5    
 	

vJJ##2	
r   c                    V P                   P                  RR.4       V P                  \        V P                   P                  R4       R# )z
If the value returned doesn't match one the expected keys of the
current multiple C{get} command, an error is raised error in
L{MemCacheProtocol.dataReceived}.
r   r"   s   VALUE egg 0 7
spamegg
END
N)r$   r2   r   r   r   r&   s   &r   test_invalidMultipleGetResponse-MemCacheTests.test_invalidMultipleGetResponse%  s<     	

/0JJ##2	
r   c                    V P                   P                  RR4       V P                  \        V P                   P                  R4       R# )z
If an END is received in response to an operation that isn't C{get},
C{gets}, or C{stats}, an error is raised in
L{MemCacheProtocol.dataReceived}.
s   keys   valuer*   N)r$   r;   r   r   r   r&   s   &r   test_invalidEndResponse%MemCacheTests.test_invalidEndResponse2  s2     	

vx(,

(?(?Lr   c                  a  S P                   P                  R4      pS P                   P                  R4      p\        4       pVP                  S P                   n        S P
                  P                  S P                   P                  4       S P                  V\        4       S P                  V\        4       V 3R lpVP                  V4       S P                  V\        4       \        WV.4      # )z
Test the timeout on outgoing requests: when timeout is detected, all
current commands fail with a L{TimeoutError}, and the connection is
closed.
r   r"   c                 >   < SP                  \        V 4      R 4       R# )zConnection timeoutN)r   str)errorr   s   &r   checkMessage0MemCacheTests.test_timeOut.<locals>.checkMessageJ  s    SZ)=>r   )r$   r%   r   callbackconnectionLostr   advancepersistentTimeOutassertFailurer   r   r   r   )r   d1d2d3r   s   f    r   test_timeOutMemCacheTests.test_timeOut;  s     ZZ^^F#ZZ^^F#Z$&KK

!

4::7782|,2|,	? 	|$2~.bb\**r   c                  a  S P                   P                  R4      pS P                  P                  S P                   P                  ^,
          4       S P                   P                  R4       V 3R lpVP                  V4       V# )zI
When a request gets a response, no pending timeout call remains around.
r   r   c                    < SP                  V R4       SP                  \        SP                  P                  4      ^ 4       R# )r!   Nr    )r   lenr   calls)r   r   s   &r   check0MemCacheTests.test_timeoutRemoved.<locals>.checkZ  s2    V[1S!1!12A6r   )r$   r%   r   r   r   r   r   )r   r   r   s   f  r   test_timeoutRemoved!MemCacheTests.test_timeoutRemovedQ  sc     JJNN6"

4::77!;<

 BC	7 	
er   c                   V P                   P                  R4      p\        4       pVP                  V P                   n        V P                   P                  R4       V P                  P                  V P                   P                  4       V P                  V\        4       V P                  V\        4       \        W.4      # )z
Test the timeout when raw mode was started: the timeout is not reset
until all the data has been received, so we can have a L{TimeoutError}
when waiting for raw data.
r   s   VALUE foo 0 10
12345)r$   r%   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   &  r   test_timeOutRawMemCacheTests.test_timeOutRawa  s     ZZ^^F#Z$&KK

!

 :;

4::7782|,2~.bX&&r   c                   V P                   P                  4       p\        4       pVP                  V P                   n        V P                   P                  R4       V P                  P                  V P                   P                  4       V P                  V\        4       V P                  V\        4       \        W.4      # )zn
Test the timeout when stat command has started: the timeout is not
reset until the final B{END} is received.
s   STAT foo bar
)r$   rt   r   r   r   r   r   r   r   r   r   r   r   r   s   &  r   test_timeOutStatMemCacheTests.test_timeOutStatq  s    
 ZZZ$&KK

!

 34

4::7782|,2~.bX&&r   c                  a aa S P                   P                  R4      pS P                   P                  R4      o\        4       pVP                  S P                   n        S P
                  P                  S P                   P                  ^,
          4       S P                   P                  R4       VVV 3R lpV 3R loVP                  V4       S P                  V\        4       V# )zt
When two requests are sent, a timeout call remains around for the
second request, and its timeout time is correct.
r   r"   r   c                 R  < SP                  V R4       SP                  \        SP                  P                  4      ^4       \	        SP
                  P                  4       F  pSP                  P                  ^4       K   	  SP                  S\        4      P                  S4      # )r!   r    )r   r   r   r   ranger$   r   r   r   r   r   )r   i	checkTimer   r   s   & r   r   3MemCacheTests.test_timeoutPipelining.<locals>.check  s{    V[1S!1!12A64::778

""1% 9%%b,7CCINNr   c                    < SP                  SP                  P                  4       ^SP                  P                  ,          ^,
          4       R# )   N)r   r   secondsr$   r   )ignoredr   s   &r   r   7MemCacheTests.test_timeoutPipelining.<locals>.checkTime  s7     TZZ//11tzz7S7S3SVW3WXr   )r$   r%   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   s   f   @@r   test_timeoutPipelining$MemCacheTests.test_timeoutPipelining  s    
 ZZ^^F#ZZ^^F#Z$&KK

!

4::77!;<

 BC	O	Y
 	u2~.	r   c                   V P                   P                  R4      p\        4       pVP                  V P                   n        V P
                  P                  V P                   P                  ^,
          4       V P                   P                  R4      pV P
                  P                  ^4       V P                  V\        4       V P                  V\        4       V P                  V\        4       \        WV.4      # )zu
Check that timeout is not resetted for every command, but keep the
timeout from the first command without response.
r   r"   )r$   r%   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   s   &   r   test_timeoutNotReset"MemCacheTests.test_timeoutNotReset  s    
 ZZ^^F#Z$&KK

!

4::77!;<ZZ^^F#

12|,2|,2~.bb\**r   c                <   V P                   P                  R4      pV P                  P                  V P                   P                  4       V P                  V\        4       V P                   P                  R4      pV P                  V\        4       \        W.4      # )z
C{timeoutConnection} cleans the list of commands that it fires with
C{TimeoutError}: C{connectionLost} doesn't try to fire them again, but
sets the disconnected state so that future commands fail with a
C{RuntimeError}.
r   r"   )	r$   r%   r   r   r   r   r   r   r   r   s   &  r   test_timeoutCleanDeferreds(MemCacheTests.test_timeoutCleanDeferreds  sq     ZZ^^F#

4::7782|,ZZ^^F#2|,bX&&r   c                   a  S P                   P                  R4      pS P                   P                  R4      pS P                  P                  4        \	        W.RR7      pV 3R lpVP                  V4      # )zT
When disconnection occurs while commands are still outstanding, the
commands fail.
r   r"   T)consumeErrorsc                 j   < V  F+  w  rSP                  V4       VP                  \        4       K-  	  R # r   )assertFalsetrapr   )resultssuccessr   r   s   &  r   checkFailures8MemCacheTests.test_connectionLost.<locals>.checkFailures  s)    #*  )N+ $+r   )r$   r%   r   loseConnectionr   r   )r   r   r   doner   s   f    r   test_connectionLost!MemCacheTests.test_connectionLost  s_    
 ZZ^^F#ZZ^^F#%%'RHD9	,
 ..r   c                \   V P                  V P                  P                  RR4      \        4      pV P                  V P                  P	                  R4      \        4      pV P                  V P                  P                  R4      \        4      pV P                  V P                  P                  RR4      \        4      pV P                  V P                  P                  RR4      \        4      pV P                  V P                  P                  RR.4      \        4      p\        WW4WV.4      # )z
An error is raised when trying to use a too long key: the called
command returns a L{Deferred} which fails with a L{ClientError}.
r"   r   s  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
r   r$   r;   r	   r^   r%   appendprependr2   r   )r   r   r   r   d4d5d6s   &      r   test_tooLongKeyMemCacheTests.test_tooLongKey  s    
 

z6 BKP

 4 4Z @+N

z :KH

 1 1*f E{S

 2 2:v FTJJ""FJ#78+
 bbb566r   c                    V P                   P                  RRR^ ^ R4      pV P                  V P                  P	                  4       R4       V P                  V\        4       V P                   P                  R4       V# )z
When an unknown command is sent directly (not through public API), the
server answers with an B{ERROR} token, and the command fails with
L{NoSuchCommand}.
rq   r   r"   r   s   egg foo 0 0 3
bar
s   ERROR
)r$   _setr   r   r   r   r   r   r   r   s   & r   test_invalidCommand!MemCacheTests.test_invalidCommand  se     JJOOFFFAq#>--/1LM1m,

-r   c                (  a  RpS P                   P                  RV4      pS P                  S P                  P	                  4       R4       S P                  V\        4       V 3R lpVP                  V4       S P                   P                  R4       V# )z
Test the L{ClientError} error: when the server sends a B{CLIENT_ERROR}
token, the originating command fails with L{ClientError}, and the error
contains the text sent by the server.
   eggspammr      set foo 0 0 8
eggspamm
c                 P   < SP                  \        V 4      \        R 4      4       R# )s   We don't like egg and spamNr   r   reprerrr   s   &r   r   -MemCacheTests.test_clientError.<locals>.check  s    SXt,I'JKr   s)   CLIENT_ERROR We don't like egg and spam
)	r$   r;   r   r   r   r   r	   r   r   r   ar   r   s   f   r   test_clientErrorMemCacheTests.test_clientError  sx     JJNN61%--/1QR1k*	L 	
e

 NOr   c                (  a  RpS P                   P                  RV4      pS P                  S P                  P	                  4       R4       S P                  V\        4       V 3R lpVP                  V4       S P                   P                  R4       V# )z
Test the L{ServerError} error: when the server sends a B{SERVER_ERROR}
token, the originating command fails with L{ServerError}, and the error
contains the text sent by the server.
r   r   r   c                 P   < SP                  \        V 4      \        R 4      4       R# )s   zomgNr   r   s   &r   r   -MemCacheTests.test_serverError.<locals>.check  s    SXtG}5r   s   SERVER_ERROR zomg
)	r$   r;   r   r   r   r   r   r   r   r  s   f   r   test_serverErrorMemCacheTests.test_serverError  sw     JJNN61%--/1QR1k*	6 	
e

 89r   c           	        V P                  V P                  P                  RR4      \        4      pV P                  V P                  P	                  R4      \        4      pV P                  V P                  P                  ^4      \        4      pV P                  V P                  P                  R4      \        4      pV P                  V P                  P                  RR4      \        4      pV P                  V P                  P                  RR4      \        4      pV P                  V P                  P                  R^.4      \        4      p\        WW4WVV.4      # )zA
Using a non-string key as argument to commands raises an error.
foor"   eggbarrq   )r   r$   r;   r	   r^   r%   rU   r   r   r2   r   )r   r   r   r   r   r   r   d7s   &       r   test_unicodeKeyMemCacheTests.test_unicodeKey  s    

uf ={K

 4 4U ;[I

q 1;?

 1 1% 8+F

 1 1% @+N

 2 25& A;O

 6 6{ C[Qbbbb9::r   c                b    V P                  V P                  P                  RR4      \        4      # )z+
Using a non-string value raises an error.
r   r  )r   r$   r;   r	   r&   s   &r   test_unicodeValueMemCacheTests.test_unicodeValue  s&     !!$**.."?MMr   c                   V P                   P                  R4      pVP                  V P                  R4       V P                   P	                  RR4      pVP                  V P                  R4       V P                   P                  R4      pVP                  V P                  R	4       V P                  V P
                  P                  4       R4       V P                   P                  R4       \        WV.4      # )
z
Multiple requests can be sent subsequently to the server, and the
protocol orders the responses correctly and dispatch to the
corresponding client command.
r   r"   s   spamspamspamTrq   s0   get foo
set bar 0 0 12
spamspamspam
get egg
s;   VALUE foo 0 3
bar
END
STORED
VALUE egg 0 4
spam
END
r    )r!   rr   )	r$   r%   r   r   r;   r   r   r   r   )r   r   r   r   s   &   r   test_pipeliningMemCacheTests.test_pipelining  s     ZZ^^F#
t''5ZZ^^FO4
t''.ZZ^^F#
t''6NN  "G	
 	

0	

 bb\**r   c                   V P                   P                  R4      pVP                  V P                  R4       V P                  V P                  P                  4       R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V# )z|
If the value retrieved by a C{get} arrive in chunks, the protocol
is able to reconstruct it and to produce the good value.
r   r   s   VALUE foo 0 10
0123456s   789s   
ENDs   
)r!   s
   0123456789)r$   r%   r   r   r   r   r   r   s   & r   test_getInChunksMemCacheTests.test_getInChunks6  s    
 JJNN6"	d&&(:;--/@

 <=

'


+

(r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z
L{MemCacheProtocol.append} behaves like a L{MemCacheProtocol.set}
method: it returns a L{Deferred} which is called back with C{True} when
the operation succeeds.
r   r"   s   append foo 0 0 3
bar
r:   T)r   r$   r   r&   s   &r   test_appendMemCacheTests.test_appendD  s2     zzJJff-*	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z
L{MemCacheProtocol.prepend} behaves like a L{MemCacheProtocol.set}
method: it returns a L{Deferred} which is called back with C{True} when
the operation succeeds.
r   r"   s   prepend foo 0 0 3
bar
r:   T)r   r$   r   r&   s   &r   test_prependMemCacheTests.test_prependQ  s2     zzJJvv.+	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z
L{MemCacheProtocol.get} handles an additional cas result when
C{withIdentifier} is C{True} and forward it in the resulting
L{Deferred}.
r   T
   gets foo
s   VALUE foo 0 3 1234
bar
END
)r!      1234r"   r#   r&   s   &r   	test_getsMemCacheTests.test_gets^  s0     zzJJNN64(3 	
 	
r   c                ^    V P                  V P                  P                  RR4      RRR4      # )z{
Test getting a non-available key with gets: it succeeds but return
L{None} as value, C{0} as flag and an empty cas value.
r   Tr!  r*   r!   r   Nr#   r&   s   &r   test_emptyGetsMemCacheTests.test_emptyGetsk  s-    
 zzJJNN64(/:~
 	
r   c           	     j    V P                  V P                  P                  RR.R4      RRRRRR/4      # )zy
L{MemCacheProtocol.getMultiple} handles an additional cas field in the
returned tuples if C{withIdentifier} is C{True}.
r   r"   T   gets foo bar
8   VALUE foo 0 3 1234
egg
VALUE bar 0 4 2345
spam
END
r!   s   2345rr   r!   r"  rq   r1   r&   s   &r   test_getsMultipleMemCacheTests.test_getsMultiplet  sB    
 zzJJ""FF#3T:U*F4HI	
 	
r   c           	     |    V P                  V P                  P                  \        RR.4      R4      RRRRRR/4      # )z?
L{MemCacheProtocol.getMultiple} accepts any iterable of keys.
r   r"   Tr*  r+  r,  r-  )r   r$   r2   iterr&   s   &r   test_getsMultipleIterableKeys+MemCacheTests.test_getsMultipleIterableKeys  sG     zzJJ""4(8#94@U*F4HI	
 	
r   c           	     j    V P                  V P                  P                  RR.R4      RRRRRR/4      # )z
When getting a non-available key with L{MemCacheProtocol.getMultiple}
when C{withIdentifier} is C{True}, the other keys are retrieved
correctly, and the non-available key gets a tuple of C{0} as flag,
L{None} as value, and an empty cas value.
r   r"   Tr*  s   VALUE foo 0 3 1234
egg
END
r&  r-  r1   r&   s   &r   test_getsMultipleWithEmpty(MemCacheTests.test_getsMultipleWithEmpty  sA     zzJJ""FF#3T:3^V-AB	
 	
r   c                b    V P                  V P                  P                  RRRR7      RRR4      # )z
L{MemCacheProtocol.checkAndSet} passes an additional cas identifier
that the server handles to check if the data has to be updated.
r   r"   r"  cas   cas foo 0 0 3 1234
bar
r:   Tr   r$   checkAndSetr&   s   &r   test_checkAndSetMemCacheTests.test_checkAndSet  s7    
 zzJJ""66w"?,	
 	
r   c                b    V P                  V P                  P                  RRRR7      RRR4      # )zl
When L{MemCacheProtocol.checkAndSet} response is C{EXISTS}, the
resulting L{Deferred} fires with C{False}.
r   r"   r"  r8  r:  s   EXISTS
Fr;  r&   s   &r   test_casUnknowKeyMemCacheTests.test_casUnknowKey  s7    
 zzJJ""66w"?,	
 	
r   r   r$   r   N)%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#  r'  r.  r2  r5  r=  r@  r   r   r   s   @r   r   r      s     
24


M+, ' ':+"'/"7
$$;N+.





	





 

r   r   c                   0   a  ] tR tRt o RtR tR tRtV tR# )CommandFailureTestsi  zN
Tests for correct failure of commands on a disconnected
L{MemCacheProtocol}.
c                ^   \        4       V n        \        4       V n        V P                  P                  V P                  n        \        4       V n        V P                  V P                  n        V P                  P                  V P                  4       V P                  P                  4        R# )zE
Create a disconnected memcache client, using a deterministic clock.
N)
r
   r$   r   r   r   r   r   r   r   r   r&   s   &r   r   CommandFailureTests.setUp  sm     &'
W
#zz33

9;"&**

!!$..1%%'r   c                .    V P                  V\        4      # )z
Implementation of C{_test} which checks that the command fails with
C{RuntimeError} because the transport is disconnected. All the
parameters except C{d} are ignored.
)r   r   r   s   &&&&&r   r   CommandFailureTests._test  s     !!!\22r   rB  N)	r   r   r   r   r   r   r   r   r   r   s   @r   rD  rD    s     

(3 3r   rD  N)r   twisted.internet.deferr   r   r   r   twisted.internet.errorr   twisted.internet.taskr   twisted.internet.testingr   twisted.protocols.memcacher	   r
   r   r   twisted.trial.unittestr   r   r   rD  r   r   r   <module>rO     sY   
 W V 1 ' E  ,UT UTpA
L( A
H3, 3r   