%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/test/__pycache__/test_memcache.cpython-312.pyc

�

Ϫ�f�b���dZddlmZmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZmZddlmZGd�d	�ZGd
�dee�ZGd�d
ee�Zy)z$
Test the memcache client protocol.
�)�Deferred�DeferredList�TimeoutError�
gatherResults)�ConnectionDone)�Clock)� StringTransportWithDisconnection)�ClientError�MemCacheProtocol�
NoSuchCommand�ServerError)�TestCasec��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�CommandMixinzO
    Setup and tests for basic invocation of L{MemCacheProtocol} commands.
    c��t��)zp
        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�_testzCommandMixin._tests
��
"�#�#�c�\�|j|jjd�ddd�S)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
�r�bar�r�proto�get�rs r�test_getzCommandMixin.test_get"s.���z�z��J�J�N�N�6�"��.��	
�	
rc�\�|j|jjd�ddd�S)zu
        Test getting a non-available key: it succeeds but return L{None} as
        value and C{0} as flag.
        rr�END
�rNr"r%s r�
test_emptyGetzCommandMixin.test_emptyGet/s&��
�z�z�$�*�*�.�.��0�.�*�i�X�Xrc�f�|j|jjddg�ddddd��S)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
s1VALUE foo 0 3
bar
VALUE cow 0 7
chicken
END
)rschickenr �r,r�rr#�getMultipler%s r�test_getMultiplezCommandMixin.test_getMultiple6s:��
�z�z��J�J�"�"�F�F�#3�4��J�$�k�:�	
�	
rc�f�|j|jjddg�ddddd��S)z�
        When L{MemCacheProtocol.getMultiple} is called with non-available keys,
        the corresponding tuples are (0, None).
        rr,r-sVALUE cow 1 3
bar
END
)�r!r)r.r/r%s r�test_getMultipleWithEmptyz&CommandMixin.test_getMultipleWithEmptyBs:��
�z�z��J�J�"�"�F�F�#3�4��.� �)�4�	
�	
rc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.set} returns a L{Deferred} which is called back with
        C{True} when the operation succeeds.
        rr!sset foo 0 0 3
bar
�STORED
T)rr#�setr%s r�test_setzCommandMixin.test_setN�0��
�z�z��J�J�N�N�6�6�*�'���	
�	
rc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.add} returns a L{Deferred} which is called back with
        C{True} when the operation succeeds.
        rr!�add foo 0 0 3
bar
r6T�rr#�addr%s r�test_addzCommandMixin.test_addZr9rc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.replace} returns a L{Deferred} which is called back
        with C{True} when the operation succeeds.
        rr!�replace foo 0 0 3
bar
r6T�rr#�replacer%s r�test_replacezCommandMixin.test_replacefs2��
�z�z��J�J���v�v�.�+���	
�	
rc�^�|j|jjdd�ddd�S)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}.
        rr!r;�NOT STORED
Fr<r%s r�
test_errorAddzCommandMixin.test_errorAddrs0���z�z��J�J�N�N�6�6�*�'���	
�	
rc�^�|j|jjdd�ddd�S)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}.
        rr!r@rEFrAr%s r�test_errorReplacezCommandMixin.test_errorReplaces2���z�z��J�J���v�v�.�+���	
�	
rc�\�|j|jjd�ddd�S)z�
        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�rr#�deleter%s r�test_deletezCommandMixin.test_delete�s.��
�z�z��J�J���f�%�'8�.�$�
�	
rc�\�|j|jjd�ddd�S)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!rJsNOT FOUND
FrKr%s r�test_errorDeletezCommandMixin.test_errorDelete�s/���z�z��J�J���f�%�'8�:J�E�
�	
rc�\�|j|jjd�ddd�S)z�
        Test incrementing a variable: L{MemCacheProtocol.increment} returns a
        L{Deferred} which is called back with the incremented value of the
        given key.
        rsincr foo 1
�4
��rr#�	incrementr%s r�test_incrementzCommandMixin.test_increment��*���z�z�$�*�*�.�.�v�6�8I�8�UV�W�Wrc�\�|j|jjd�ddd�S)z�
        Test decrementing a variable: L{MemCacheProtocol.decrement} returns a
        L{Deferred} which is called back with the decremented value of the
        given key.
        rsdecr foo 1
�5
��rr#�	decrementr%s r�test_decrementzCommandMixin.test_decrement�rVrc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.increment} takes an optional argument C{value} which
        replaces the default value of 1 when specified.
        r�sincr foo 8
rQrRrSr%s r�test_incrementValzCommandMixin.test_incrementVal��0��
�z�z��J�J� � ���+�->��!�
�	
rc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.decrement} takes an optional argument C{value} which
        replaces the default value of 1 when specified.
        r�sdecr foo 3
rXrYrZr%s r�test_decrementValzCommandMixin.test_decrementVal�r`rc�`�|j|jj�ddddd��S)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.
        sstats
�"STAT foo bar
STAT egg spam
END
r!�spam�r�egg�rr#�statsr%s r�
test_statszCommandMixin.test_stats�s3���z�z��J�J�����7��W�-�	
�	
rc�b�|j|jjd�ddddd��S)a9
        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).
        sblahsstats blah
rer!rfrgrir%s r�test_statsWithArgumentz#CommandMixin.test_statsWithArgument�s5���z�z��J�J���W�%��7��W�-�	
�	
rc�Z�|j|jj�ddd�S)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
s1.1)rr#�versionr%s r�test_versionzCommandMixin.test_version�s,���z�z��J�J��� �.�2D�f�
�	
rc�Z�|j|jj�ddd�S)z�
        L{MemCacheProtocol.flushAll} returns a L{Deferred} which is called back
        with C{True} if the server acknowledges success.
        sflush_all
sOK
T)rr#�flushAllr%s r�
test_flushAllzCommandMixin.test_flushAll�s'��
�z�z�$�*�*�-�-�/�1A�9�d�S�SrN)�__name__�
__module__�__qualname__�__doc__rr&r*r1r4r8r>rCrFrHrMrOrUr\r_rcrkrmrprs�rrrrso���$�
�Y�

�

�

�

�

�
�
�
�
�X�X�
�
�
�
�
�Trrc���eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!y )!�
MemCacheTestsz9
    Test client protocol class L{MemCacheProtocol}.
    c�(�t�|_t�|_|jj|j_t�|_|j|j_|jj|j�y)z{
        Create a memcache client, connect it to a string protocol, and make it
        use a deterministic clock.
        N)	rr#r�clock�	callLaterr	�	transport�protocol�makeConnectionr%s r�setUpzMemCacheTests.setUp�s]��
&�'��
��W��
�#�z�z�3�3��
�
��9�;���"&�*�*������
�
�!�!�$�.�.�1rc�������fd�}�j�jj�|�|j|��jj|�|S)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�*���j|��y�N)�assertEqual)�resrrs ��r�cbzMemCacheTests._test.<locals>.cbs������S�&�)r)r�r~�value�addCallbackr#�dataReceived)rrrrrr�s`   ` rrzMemCacheTests._test�sJ���$	*�	
������-�-�/��6�	�
�
�b���
�
����%��rc��|jjd�|jt|jjd�y)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}.
        rsVALUE bar 0 7
spamegg
END
N)r#r$�assertRaises�RuntimeErrorr�r%s r�test_invalidGetResponsez%MemCacheTests.test_invalidGetResponses5��
	
�
�
���v�������J�J�#�#�2�	
rc��|jjddg�|jt|jjd�y)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}.
        rr!sVALUE egg 0 7
spamegg
END
N)r#r0r�r�r�r%s r�test_invalidMultipleGetResponsez-MemCacheTests.test_invalidMultipleGetResponse%s<��	
�
�
�����/�0������J�J�#�#�2�	
rc��|jjdd�|jt|jjd�y)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}.
        skeysvaluer(N)r#r7r�r�r�r%s r�test_invalidEndResponsez%MemCacheTests.test_invalidEndResponse2s2��	
�
�
���v�x�(����,��
�
�(?�(?��Lrc�����jjd�}�jjd�}t�}|j�j_�j
j
�jj��j|t��j|t��fd�}|j|��j|t�t|||g�S)z�
        Test the timeout on outgoing requests: when timeout is detected, all
        current commands fail with a L{TimeoutError}, and the connection is
        closed.
        rr!c�<���jt|�d�y)NzConnection timeout)r��str)�errorrs �r�checkMessagez0MemCacheTests.test_timeOut.<locals>.checkMessageJs������S��Z�)=�>r)
r#r$r�callback�connectionLostr|�advance�persistentTimeOut�
assertFailurerr�rr)r�d1�d2�d3r�s`    r�test_timeOutzMemCacheTests.test_timeOut;s�����Z�Z�^�^�F�
#��
�Z�Z�^�^�F�
#��
�Z��$&�K�K��
�
�!��
�
���4�:�:�7�7�8����2�|�,����2�|�,�	?�	���|�$����2�~�.��b�"�b�\�*�*rc����jjd�}�jj�jjdz
��jjd��fd�}|j
|�|S)zY
        When a request gets a response, no pending timeout call remains around.
        rr3rc����j|d��jt�jj�d�y)Nr r)r��lenr|�calls)rrs �r�checkz0MemCacheTests.test_timeoutRemoved.<locals>.checkZs2������V�[�1����S����!1�!1�2�A�6r)r#r$r|r�r�r�r�)rrr�s`  r�test_timeoutRemovedz!MemCacheTests.test_timeoutRemovedQsc���
�J�J�N�N�6�"���
�
���4�:�:�7�7�!�;�<��
�
��� B�C�	7�	
�
�
�e���rc��|jjd�}t�}|j|j_|jjd�|jj|jj�|j|t�|j|t�t||g�S)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.
        rsVALUE foo 0 10
12345)
r#r$rr�r�r�r|r�r�r�rrr�rr�r�s   r�test_timeOutRawzMemCacheTests.test_timeOutRawas����Z�Z�^�^�F�
#��
�Z��$&�K�K��
�
�!��
�
��� :�;��
�
���4�:�:�7�7�8����2�|�,����2�~�.��b�"�X�&�&rc��|jj�}t�}|j|j_|jjd�|jj|jj�|j|t�|j|t�t||g�S)z�
        Test the timeout when stat command has started: the timeout is not
        reset until the final B{END} is received.
        sSTAT foo bar
)
r#rjrr�r�r�r|r�r�r�rrrr�s   r�test_timeOutStatzMemCacheTests.test_timeOutStatqs���
�Z�Z�
�
�
��
�Z��$&�K�K��
�
�!��
�
��� 3�4��
�
���4�:�:�7�7�8����2�|�,����2�~�.��b�"�X�&�&rc�������jjd�}�jjd��t�}|j�j_�j
j
�jjdz
��jjd����fd�}�fd��|j|��j|t�|S)z�
        When two requests are sent, a timeout call remains around for the
        second request, and its timeout time is correct.
        rr!r3rc�N���j|d��jt�jj�d�t	�j
j�D]}�jjd���j�t�j��S)Nr r3)r�r�r|r��ranger#r�r�r�rr�)r�i�	checkTimer�rs  ���rr�z3MemCacheTests.test_timeoutPipelining.<locals>.check�s�������V�[�1����S����!1�!1�2�A�6��4�:�:�7�7�8�
&���
�
�"�"�1�%�
&��%�%�b�,�7�C�C�I�N�Nrc����j�jj�d�jjzdz
�y)N�r3)r�r|�secondsr#r�)�ignoredrs �rr�z7MemCacheTests.test_timeoutPipelining.<locals>.checkTime�s7���
���T�Z�Z�/�/�1�1�t�z�z�7S�7S�3S�VW�3W�Xr)r#r$rr�r�r|r�r�r�r�r�r)rr�r�r�r�r�s`   @@r�test_timeoutPipeliningz$MemCacheTests.test_timeoutPipelining�s����
�Z�Z�^�^�F�
#��
�Z�Z�^�^�F�
#��
�Z��$&�K�K��
�
�!��
�
���4�:�:�7�7�!�;�<��
�
��� B�C�	O�	Y�
	���u�����2�~�.��	rc���|jjd�}t�}|j|j_|j
j
|jjdz
�|jjd�}|j
j
d�|j|t�|j|t�|j|t�t|||g�S)z�
        Check that timeout is not resetted for every command, but keep the
        timeout from the first command without response.
        rr3r!)r#r$rr�r�r|r�r�r�rrr)rr�r�r�s    r�test_timeoutNotResetz"MemCacheTests.test_timeoutNotReset�s���
�Z�Z�^�^�F�
#��
�Z��$&�K�K��
�
�!��
�
���4�:�:�7�7�!�;�<�
�Z�Z�^�^�F�
#���
�
���1�����2�|�,����2�|�,����2�~�.��b�"�b�\�*�*rc�>�|jjd�}|jj|jj�|j|t�|jjd�}|j|t�t||g�S)a
        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}.
        rr!)	r#r$r|r�r�r�rr�rr�s   r�test_timeoutCleanDeferredsz(MemCacheTests.test_timeoutCleanDeferreds�ss���Z�Z�^�^�F�
#���
�
���4�:�:�7�7�8����2�|�,�
�Z�Z�^�^�F�
#�����2�|�,��b�"�X�&�&rc�����jjd�}�jjd�}�jj�t	||gd��}�fd�}|j|�S)zl
        When disconnection occurs while commands are still outstanding, the
        commands fail.
        rr!T)�
consumeErrorsc�f��|D]+\}}�j|�|jt��-yr�)�assertFalse�trapr)�results�successrrs   �r�
checkFailuresz8MemCacheTests.test_connectionLost.<locals>.checkFailures�s0���#*�
,����� � ��)����N�+�
,r)r#r$r~�loseConnectionrr�)rr�r��doner�s`    r�test_connectionLostz!MemCacheTests.test_connectionLost�sa���
�Z�Z�^�^�F�
#��
�Z�Z�^�^�F�
#�����%�%�'��R��H�D�9��	,�
���
�.�.rc�b�|j|jjdd�t�}|j|jj	d�t�}|j|jjd�t�}|j|jj
dd�t�}|j|jjdd�t�}|j|jjddg�t�}t||||||g�S)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}.
        s�aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar!r)
r�r#r7r
rTr$�append�prependr0r)rr�r�r��d4�d5�d6s       r�test_tooLongKeyzMemCacheTests.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�6rc��|jjdddddd�}|j|jj	�d�|j|t�|jjd�|S)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}.
        rhrr!rrsegg foo 0 0 3
bar
sERROR
)r#�_setr�r~r�r�rr��rrs  r�test_invalidCommandz!MemCacheTests.test_invalidCommand�se��
�J�J�O�O�F�F�F�A�q�#�>��������-�-�/�1L�M����1�m�,��
�
����-��rc�&��d}�jjd|�}�j�jj	�d��j|t��fd�}|j|��jjd�|S)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�N���jt|�td��y)NsWe don't like egg and spam�r�r��repr��errrs �rr�z-MemCacheTests.test_clientError.<locals>.check�s������S��X�t�,I�'J�Krs)CLIENT_ERROR We don't like egg and spam
)	r#r7r�r~r�r�r
r�r��r�arr�s`   r�test_clientErrorzMemCacheTests.test_clientError�sx���
���J�J�N�N�6�1�%��������-�-�/�1Q�R����1�k�*�	L�	
�
�
�e���
�
��� N�O��rc�&��d}�jjd|�}�j�jj	�d��j|t��fd�}|j|��jjd�|S)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�rr�c�N���jt|�td��y)Nszomgr�r�s �rr�z-MemCacheTests.test_serverError.<locals>.checks������S��X�t�G�}�5rsSERVER_ERROR zomg
)	r#r7r�r~r�r�r
r�r�r�s`   r�test_serverErrorzMemCacheTests.test_serverError�sw���
���J�J�N�N�6�1�%��������-�-�/�1Q�R����1�k�*�	6�	
�
�
�e���
�
��� 8�9��rc	���|j|jjdd�t�}|j|jj	d�t�}|j|jjd�t�}|j|jj
d�t�}|j|jjdd�t�}|j|jjdd�t�}|j|jjddg�t�}t|||||||g�S)zQ
        Using a non-string key as argument to commands raises an error.
        �foor!�eggr3�barrh)r�r#r7r
rTr$rLr�r�r0r)rr�r�r�r�r�r��d7s        r�test_unicodeKeyzMemCacheTests.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�:�:rc�b�|j|jjdd�t�S)z;
        Using a non-string value raises an error.
        rr�)r�r#r7r
r%s r�test_unicodeValuezMemCacheTests.test_unicodeValues&���!�!�$�*�*�.�.���"?��M�Mrc���|jjd�}|j|jd�|jj	dd�}|j|jd�|jjd�}|j|jd�|j|j
j
�d�|jjd	�t|||g�S)
z�
        Multiple requests can be sent subsequently to the server, and the
        protocol orders the responses correctly and dispatch to the
        corresponding client command.
        rr r!sspamspamspamTrh)rrfs0get 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$r�r�r7r~r�r�r)rr�r�r�s    r�test_pipeliningzMemCacheTests.test_pipelinings����Z�Z�^�^�F�
#��
���t�'�'��5�
�Z�Z�^�^�F�O�
4��
���t�'�'��.�
�Z�Z�^�^�F�
#��
���t�'�'��6�����N�N� � �"�G�	
�	
�
�
���
0�	
�
�b�"�b�\�*�*rc��|jjd�}|j|jd�|j|jj�d�|jj
d�|jj
d�|jj
d�|jj
d�|S)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)rs
0123456789rsVALUE foo 0 10
0123456s789s
ENDs
)r#r$r�r�r~r�r�r�s  r�test_getInChunkszMemCacheTests.test_getInChunks6s���

�J�J�N�N�6�"��	�
�
�d�&�&�(:�;�������-�-�/��@��
�
��� <�=��
�
����'��
�
���
�+��
�
����(��rc�^�|j|jjdd�ddd�S)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.
        rr!sappend foo 0 0 3
bar
r6T)rr#r�r%s r�test_appendzMemCacheTests.test_appendDs2���z�z��J�J���f�f�-�*���	
�	
rc�^�|j|jjdd�ddd�S)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.
        rr!sprepend foo 0 0 3
bar
r6T)rr#r�r%s r�test_prependzMemCacheTests.test_prependQs2���z�z��J�J���v�v�.�+���	
�	
rc�^�|j|jjdd�ddd�S)z�
        L{MemCacheProtocol.get} handles an additional cas result when
        C{withIdentifier} is C{True} and forward it in the resulting
        L{Deferred}.
        rT�
gets foo
sVALUE foo 0 3 1234
bar
END
)r�1234r!r"r%s r�	test_getszMemCacheTests.test_gets^s0���z�z��J�J�N�N�6�4�(��3� �	
�	
rc�^�|j|jjdd�ddd�S)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.
        rTr�r(�rrNr"r%s r�test_emptyGetszMemCacheTests.test_emptyGetsks-��
�z�z��J�J�N�N�6�4�(�/�:�~�
�	
rc�h�|j|jjddgd�ddddd��S)	z�
        L{MemCacheProtocol.getMultiple} handles an additional cas field in the
        returned tuples if C{withIdentifier} is C{True}.
        rr!T�gets foo bar
�8VALUE foo 0 3 1234
egg
VALUE bar 0 4 2345
spam
END
�rs2345rf�rr�rh�r!rr/r%s r�test_getsMultiplezMemCacheTests.test_getsMultiplets=��
�z�z��J�J�"�"�F�F�#3�T�:��U�*�4H�I�	
�	
rc�z�|j|jjtddg�d�ddddd��S)	zO
        L{MemCacheProtocol.getMultiple} accepts any iterable of keys.
        rr!Tr�r�r�r�r�)rr#r0�iterr%s r�test_getsMultipleIterableKeysz+MemCacheTests.test_getsMultipleIterableKeys�sB���z�z��J�J�"�"�4���(8�#9�4�@��U�*�4H�I�	
�	
rc�h�|j|jjddgd�ddddd��S)	a
        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.
        rr!Tr�sVALUE foo 0 3 1234
egg
END
r�r�r�r/r%s r�test_getsMultipleWithEmptyz(MemCacheTests.test_getsMultipleWithEmpty�s=���z�z��J�J�"�"�F�F�#3�T�:��3�#�-A�B�	
�	
rc�b�|j|jjddd��ddd�S)z�
        L{MemCacheProtocol.checkAndSet} passes an additional cas identifier
        that the server handles to check if the data has to be updated.
        rr!r���cas�cas foo 0 0 3 1234
bar
r6T�rr#�checkAndSetr%s r�test_checkAndSetzMemCacheTests.test_checkAndSet�s7��
�z�z��J�J�"�"�6�6�w�"�?�,���	
�	
rc�b�|j|jjddd��ddd�S)z�
        When L{MemCacheProtocol.checkAndSet} response is C{EXISTS}, the
        resulting L{Deferred} fires with C{False}.
        rr!r�rrsEXISTS
Frr%s r�test_casUnknowKeyzMemCacheTests.test_casUnknowKey�s7��
�z�z��J�J�"�"�6�6�w�"�?�,���	
�	
rN)"rtrurvrwr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rxrrrzrz�s����
2��4

�
�M�+�,� '� 
'��:+�"'�/�"
7�
��$�$;�N�+�.�
�
�
�
�

�	
�
�

�

rrzc��eZdZdZd�Zd�Zy)�CommandFailureTestszZ
    Tests for correct failure of commands on a disconnected
    L{MemCacheProtocol}.
    c�\�t�|_t�|_|jj|j_t�|_|j|j_|jj|j�|jj�y)zU
        Create a disconnected memcache client, using a deterministic clock.
        N)
rr#rr|r}r	r~rr�r�r%s rr�zCommandFailureTests.setUp�sm��&�'��
��W��
�#�z�z�3�3��
�
��9�;���"&�*�*������
�
�!�!�$�.�.�1����%�%�'rc�.�|j|t�S)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�rs     rrzCommandFailureTests._test�s���!�!�!�\�2�2rN)rtrurvrwr�rrxrrrr�s���

(�3rrN)rw�twisted.internet.deferrrrr�twisted.internet.errorr�twisted.internet.taskr�twisted.internet.testingr	�twisted.protocols.memcacher
rrr
�twisted.trial.unittestrrrzrrxrr�<module>rsY���
W�V�1�'�E���,�UT�UT�pA
�L�(�A
�H3�,��3r

Zerion Mini Shell 1.0