+
    üÐjÂb  ã                   ó®   € 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.   € ð �z‰zØ�J‰J�N‰N˜6Ó"ØØ.Øó	
ð 	
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&   € ð
 �z‰z˜$Ÿ*™*Ÿ.™.¨Ó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>   € ð
 �z‰zØ�J‰J×"Ñ" F¨FÐ#3Ó4ØØJØ�_ f¨kÐ:ó	
ð 	
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>   € ð
 �z‰zØ�J‰J×"Ñ" F¨FÐ#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   € ð
 �z‰zØ�J‰J�N‰N˜6 6Ó*Ø'ØØó	
ð 	
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   € ð
 �z‰zØ�J‰J×Ñ˜v vÓ.Ø+ØØó	
ð 	
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   € ð �z‰zØ�J‰J�N‰N˜6 6Ó*Ø'ØØó	
ð 	
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   € ð �z‰zØ�J‰J×Ñ˜v vÓ.Ø+ØØó	
ð 	
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.   € ð
 �z‰zØ�J‰J×Ñ˜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/   € ð �z‰zØ�J‰J×Ñ˜fÓ%Ð'8Ð:JÈEó
ð 	
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Ÿ   ó*   € ð �z‰z˜$Ÿ*™*×.Ñ.¨vÓ6Ð8IÈ8ÐUVÓ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   € ð
 �z‰zØ�J‰J× Ñ  ¨Ó+Ð->ÀÈ!ó
ð 	
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   € ð �z‰zØ�J‰J×ÑÓØØ7Ø�V˜V WÐ-ó	
ð 	
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   € ð �z‰zØ�J‰J×Ñ˜WÓ%ØØ7Ø�V˜V WÐ-ó	
ð 	
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,   € ð �z‰zØ�J‰J×ÑÓ  .Ð2DÀfó
ð 	
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'   € ð
 �z‰z˜$Ÿ*™*×-Ñ-Ó/Ð1AÀ9ÈdÓ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ˆŒ
Ø#Ÿz™z×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ÔØ×ÑÜØ�J‰J×#Ñ#Ø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Ø×ÑÜØ�J‰J×#Ñ#Ø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   € ð 	�
‰
�‰�v˜xÔ(Ø×Ñœ,¨¯
©
×(?Ñ(?ÀÖ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   ÚcheckMessageÚ0MemCacheTests.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®   ø€ ð �Z‰Z�^‰^˜FÓ#ˆØ�Z‰Z�^‰^˜FÓ#ˆÜ‹ZˆØ$&§K¡Kˆ�
‰
Ô!à�
‰
×Ñ˜4Ÿ:™:×7Ñ7Ô8Ø×Ñ˜2œ|Ô,Ø×Ñ˜2œ|Ô,õ	?ð 	�‰�|Ô$Ø×Ñ˜2œ~Ô.Ü˜b b˜\Ó*Ð*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   ÚcheckÚ0MemCacheTests.test_timeoutRemoved.<locals>.checkZ  s2   ø€ Ø×Ñ˜V [Ô1Ø×ÑœS §¡×!1Ñ!1Ó2°AÖ6r   )r$   r%   r�   r´   rµ   rŸ   rž   )r   r   rÀ   s   f  r   Útest_timeoutRemovedÚ!MemCacheTests.test_timeoutRemovedQ  sc   ø€ ð �J‰J�N‰N˜6Ó"ˆà�
‰
×Ñ˜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‰   € ð �Z‰Z�^‰^˜FÓ#ˆÜ‹ZˆØ$&§K¡Kˆ�
‰
Ô!à�
‰
×ÑÐ :Ô;Ø�
‰
×Ñ˜4Ÿ:™:×7Ñ7Ô8Ø×Ñ˜2œ|Ô,Ø×Ñ˜2œ~Ô.Ü˜b˜XÓ&Ð&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‰   € ð
 �Z‰Z×ÑÓˆÜ‹ZˆØ$&§K¡Kˆ�
‰
Ô!à�
‰
×ÑÐ 3Ô4Ø�
‰
×Ñ˜4Ÿ:™:×7Ñ7Ô8Ø×Ñ˜2œ|Ô,Ø×Ñ˜2œ~Ô.Ü˜b˜XÓ&Ð&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Ó2°AÔ6Ü˜4Ÿ:™:×7Ñ7Ö8�Ø—
‘
×"Ñ" 1Ö%ñ 9à×%Ñ% b¬,Ó7×CÑCÀIÓ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   ø€ ð ×Ñ˜TŸZ™Z×/Ñ/Ó1°1°t·z±z×7SÑ7SÕ3SÐVWÕ3WÖ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£   ú€ ð
 �Z‰Z�^‰^˜FÓ#ˆØ�Z‰Z�^‰^˜FÓ#ˆÜ‹ZˆØ$&§K¡Kˆ�
‰
Ô!à�
‰
×Ñ˜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±   € ð
 �Z‰Z�^‰^˜FÓ#ˆÜ‹ZˆØ$&§K¡Kˆ�
‰
Ô!à�
‰
×Ñ˜4Ÿ:™:×7Ñ7¸!Õ;Ô<Ø�Z‰Z�^‰^˜FÓ#ˆØ�
‰
×Ñ˜1ÔØ×Ñ˜2œ|Ô,Ø×Ñ˜2œ|Ô,Ø×Ñ˜2œ~Ô.Ü˜b b˜\Ó*Ð*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   € ð �Z‰Z�^‰^˜FÓ#ˆØ�
‰
×Ñ˜4Ÿ:™:×7Ñ7Ô8Ø×Ñ˜2œ|Ô,Ø�Z‰Z�^‰^˜FÓ#ˆØ×Ñ˜2œ|Ô,Ü˜b˜XÓ&Ð&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   ÚcheckFailuresÚ8MemCacheTests.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_   ø€ ð
 �Z‰Z�^‰^˜FÓ#ˆØ�Z‰Z�^‰^˜FÓ#ˆØ�‰×%Ñ%Ô'Ü˜R˜H°DÔ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è   € ð
 ×Ñ §
¡
§¡¨z¸6Ó BÄKÓPˆØ×Ñ §
¡
× 4Ñ 4°ZÓ @Ä+ÓNˆØ×Ñ §
¡
§¡¨zÓ :¼KÓHˆØ×Ñ §
¡
× 1Ñ 1°*¸fÓ EÄ{ÓSˆØ×Ñ §
¡
× 2Ñ 2°:¸vÓ FÌÓTˆØ×ÑØ�J‰J×"Ñ" F¨JÐ#7Ó8¼+ó
ˆô ˜b b¨bÐ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   € ð �J‰J�O‰O˜F F¨F°A°q¸#Ó>ˆØ×Ñ˜Ÿ™×-Ñ-Ó/Ð1LÔMØ×Ñ˜1œmÔ,Ø�
‰
×Ñ Ô-Øˆ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 ›X¤tÐ,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   ø€ ð ˆØ�J‰J�N‰N˜6 1Ó%ˆØ×Ñ˜Ÿ™×-Ñ-Ó/Ð1QÔRØ×Ñ˜1œkÔ*õ	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 ›X¤t¨G£}Ö5r   s   SERVER_ERROR zomg
)	r$   r;   r™   r‘   r�   r¶   r   rž   rŸ   r  s   f   r   Útest_serverErrorÚMemCacheTests.test_serverErrorú  sw   ø€ ð ˆØ�J‰J�N‰N˜6 1Ó%ˆØ×Ñ˜Ÿ™×-Ñ-Ó/Ð1QÔRØ×Ñ˜1œkÔ*õ	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  € ð ×Ñ §
¡
§¡¨u°fÓ =¼{ÓKˆØ×Ñ §
¡
× 4Ñ 4°UÓ ;¼[ÓIˆØ×Ñ §
¡
§¡¨qÓ 1´;Ó?ˆØ×Ñ §
¡
× 1Ñ 1°%Ó 8¼+ÓFˆØ×Ñ §
¡
× 1Ñ 1°%¸Ó @Ä+ÓNˆØ×Ñ §
¡
× 2Ñ 2°5¸&Ó AÄ;ÓOˆØ×Ñ §
¡
× 6Ñ 6¸À°{Ó CÄ[ÓQˆÜ˜b b¨b°bÐ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Ã   € ð �Z‰Z�^‰^˜FÓ#ˆØ
�‰�t×'Ñ'¨Ô5Ø�Z‰Z�^‰^˜F OÓ4ˆØ
�‰�t×'Ñ'¨Ô.Ø�Z‰Z�^‰^˜FÓ#ˆØ
�‰�t×'Ñ'¨Ô6Ø×ÑØ�N‰N× Ñ Ó"ØGô	
ð 	�
‰
×Ñð0ô	
ô
 ˜b b˜\Ó*Ð*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–   € ð
 �J‰J�N‰N˜6Ó"ˆØ	�‰�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   € ð �z‰zØ�J‰J×Ñ˜f fÓ-Ø*ØØó	
ð 	
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   € ð �z‰zØ�J‰J×Ñ˜v vÓ.Ø+ØØó	
ð 	
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   € ð �z‰zØ�J‰J�N‰N˜6 4Ó(ØØ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-   € ð
 �z‰zØ�J‰J�N‰N˜6 4Ó(¨/¸:À~ó
ð 	
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   € ð
 �z‰zØ�J‰J×"Ñ" F¨FÐ#3°TÓ:ØØUØÐ*¨FÐ4HÐ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   € ð �z‰zØ�J‰J×"Ñ"¤4¨°Ð(8Ó#9¸4Ó@ØØUØÐ*¨FÐ4HÐ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   € ð �z‰zØ�J‰J×"Ñ" F¨FÐ#3°TÓ:ØØ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   € ð
 �z‰zØ�J‰J×"Ñ" 6¨6°wÐ"Ó?Ø,ØØó	
ð 	
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   € ð
 �z‰zØ�J‰J×"Ñ" 6¨6°wÐ"Ó?Ø,ØØó	
ð 	
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ˆŒ
Ø#Ÿz™z×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   