o
    ¼>hÄ  ã                   @   sv   d dl mZ d dlmZmZmZ d dlmZmZ d dl	m
Z
 G dd„ dejƒZG dd„ dejƒZG d	d
„ d
e
jƒZdS )é    )ÚBytesIO)ÚabstractÚdeferÚprotocol)ÚbasicÚloopback)Úunittestc                   @   s"   e Zd ZdZdeddfdd„ZdS )ÚBufferingServeró    ÚdataÚreturnNc                 C   s   |  j |7  _ d S ©N)Úbuffer)Úselfr   © r   úx/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/test/test_tpfile.pyÚdataReceived   ó   zBufferingServer.dataReceived)Ú__name__Ú
__module__Ú__qualname__r   Úbytesr   r   r   r   r   r	      s    r	   c                   @   s(   e Zd Zdeddfdd„Zddd„ZdS )	ÚFileSendingClientÚfr   Nc                 C   s
   || _ d S r   )r   )r   r   r   r   r   Ú__init__   s   
zFileSendingClient.__init__c                    sB   ˆ j d usJ ‚t ¡ }| ˆ jˆ j dd„ ¡}| ‡ fdd„¡ d S )Nc                 S   ó   | S r   r   ©Úxr   r   r   Ú<lambda>   ó    z2FileSendingClient.connectionMade.<locals>.<lambda>c                    s
   ˆ j  ¡ S r   )Ú	transportÚloseConnection)Úr©r   r   r   r      s   
 )r    r   Ú
FileSenderÚbeginFileTransferr   ÚaddCallback)r   ÚsÚdr   r#   r   ÚconnectionMade   s   z FileSendingClient.connectionMade©r   N)r   r   r   r   r   r)   r   r   r   r   r      s    r   c                   @   s*   e Zd Zdejd fdd„Zddd„ZdS )ÚFileSenderTestsr   Nc                    sF   d‰t ƒ ‰ ttˆƒƒ}t ˆ |¡}dtdd f‡ ‡‡fdd„}| |¡S )Ns„  xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123r   r   c                    s   ˆ  ˆ jˆ¡ d S r   )ÚassertEqualr   r   ©r'   r   ÚtestStrr   r   Úcallback&   r   z1FileSenderTests.testSendingFile.<locals>.callback)r	   r   r   r   ÚloopbackTCPÚobjectr&   )r   Úcr(   r/   r   r-   r   ÚtestSendingFile   s   
zFileSenderTests.testSendingFilec                 C   sN   t  ¡ }t ¡ }d|_tdƒ}| ||dd„ ¡}|  |j¡ |  	|j
d¡ d S )Né   r
   c                 S   r   r   r   r   r   r   r   r   1   r   z6FileSenderTests.testSendingEmptyFile.<locals>.<lambda>z0producer unregistered with deferred being called)r   r$   r   ÚFileDescriptorÚ	connectedr   r%   ÚassertIsNoneÚproducerÚ
assertTrueÚcalled)r   Ú
fileSenderÚconsumerÚ	emptyFiler(   r   r   r   ÚtestSendingEmptyFile+   s   z$FileSenderTests.testSendingEmptyFiler*   )r   r   r   r   ÚDeferredr3   r>   r   r   r   r   r+      s    r+   N)Úior   Útwisted.internetr   r   r   Útwisted.protocolsr   r   Útwisted.trialr   ÚProtocolr	   r   ÚTestCaser+   r   r   r   r   Ú<module>   s   