o
    Óó·iÄ  ã                   @   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   ú^C:\Users\psant\Downloads\PAF backend\school\venv\Lib\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   )Ú	transportZ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   ZtestStrr   r   Úcallback&   r   z1FileSenderTests.testSendingFile.<locals>.callback)r	   r   r   r   Z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   ZFileDescriptorÚ	connectedr   r$   ZassertIsNoneZproducerÚ
assertTrueÚcalled)r   Z
fileSenderZconsumerZ	emptyFiler'   r   r   r   ÚtestSendingEmptyFile+   s   z$FileSenderTests.testSendingEmptyFiler)   )r   r   r   r   ZDeferredr0   r5   r   r   r   r   r*      s    r*   N)Úior   Ztwisted.internetr   r   r   Ztwisted.protocolsr   r   Ztwisted.trialr   ÚProtocolr	   r   ZTestCaser*   r   r   r   r   Ú<module>   s   