o
    ju                     @   sV   d dl Z d dlmZmZmZ d dlmZ d dlmZ d dl	m
Z
 G dd de
jZdS )    N)ApplicationServicerpc)Unicode)MessagePackDocument)unittestc                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestMessagePackServerc                 C   sJ   ddl m} ddlm} ddlm} |||}| }|| ||_|S )Nr   )TwistedMessagePackProtocol) StringTransportWithDisconnection)MessagePackServerBase)spyne.server.twisted.msgpackr	   twisted.test.proto_helpersr
   spyne.server.msgpackr   makeConnectionprotocol)selfappr	   r
   r   prot	transport r   a/var/www/html/LicenciasMiG/venv/lib/python3.10/site-packages/spyne/test/transport/test_msgpack.pygen_prot   s   
zTestMessagePackServer.gen_protc                 C   s   d}G dd dt }t|gdt t d}| |}td|gi}|td|g |j }t	t
| t|}t	t
| | |dt|g d S )	Nyaaay!c                   @   s    e Zd Zeeeddd ZdS )z9TestMessagePackServer.test_roundtrip.<locals>.SomeService_returnsc                 S   s   |S Nr   )ctxur   r   r   yay-   s   z=TestMessagePackServer.test_roundtrip.<locals>.SomeService.yayN__name__
__module____qualname__r   r   r   r   r   r   r   SomeService,   s    
r#   tnsin_protocolout_protocolr      r   )r   r   r   r   msgpackpackbdataReceivedr   valueprintreprunpackbassertEqual)r   vr#   r   r   requestvalr   r   r   test_roundtrip*   s   


z$TestMessagePackServer.test_roundtripc                    s   ddl m ddlm  dg G  fdddt}t|gdt t d}|t	d	gi}fd
d}
t	d|g d jd |S )Nr   )reactor)
deferLaterr   c                       s(   e Zd Zeeed fddZdS )zBTestMessagePackServer.test_roundtrip_deferred.<locals>.SomeServicer   c                    s"    fdd} |  d|S )Nc                      s    S r   r   r   r   r   r   _cbH   s   zSTestMessagePackServer.test_roundtrip_deferred.<locals>.SomeService.yay.<locals>._cbg?)append)r   r   r8   r6   p_ctxr5   r7   r   r   F   s   
zFTestMessagePackServer.test_roundtrip_deferred.<locals>.SomeService.yayNr   r   r:   r   r   r#   E   s    
r#   r$   r%   r   c                    sF    j  }tt| t|}tt| |dtg d S )Nr   )r   r,   r-   r.   r)   r/   r0   r*   )_r3   )r   r   r1   r   r   _ccbS   s
   

z;TestMessagePackServer.test_roundtrip_deferred.<locals>._ccbr(   )twisted.internetr5   twisted.internet.taskr6   r   r   r   r   r)   r*   r+   
out_objectaddCallback)r   r#   r   r2   r=   r   )r6   r;   r   r5   r   r1   r   test_roundtrip_deferred?   s   
z-TestMessagePackServer.test_roundtrip_deferredN)r    r!   r"   r   r4   rB   r   r   r   r   r      s    r   )r)   spyner   r   r   spyne.modelr   spyne.protocol.msgpackr   twisted.trialr   TestCaser   r   r   r   r   <module>   s   