o
    i1                     @   s   d dl Z e dZee j d dlZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d d	lmZ G d
d dejZedkrRe  dS dS )    Nzeep)datetime)	b64encode	b64decode)server_started)six)Client)	Transport)Errorc                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dES )FTestZeepc                 C   sD   ddl m} |d t \}tdd}td| |d| _d| _d S )	Nr   )
run_serverhttpF)cachezhttp://localhost:%d/?wsdl)	transportzspyne.test.interop.server))spyne.test.interop._test_soap_client_baser   r   keysr	   r   clientns)selfr   portr    r   \/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/test/interop/test_zeep.pysetUp'   s   


zTestZeep.setUpc                 C   s   | j | S N)r   get_type)r   whatr   r   r   get_inst2   s   zTestZeep.get_instc                 C   &   t  }| jj|}||ksJ d S r   )r   nowr   serviceecho_datetimer   valretr   r   r   test_echo_datetime5      zTestZeep.test_echo_datetimec                 C   r   r   )r   r   r   r   !echo_datetime_with_invalid_formatr!   r   r   r   &test_echo_datetime_with_invalid_format;   r%   z/TestZeep.test_echo_datetime_with_invalid_formatc                 C   *   t   }| jj|}||ksJ d S r   )r   r   dater   r   	echo_dater!   r   r   r   test_echo_dateA      zTestZeep.test_echo_datec                 C   r(   r   )r   r   r)   r   r   echo_date_with_invalid_formatr!   r   r   r   "test_echo_date_with_invalid_formatG   r,   z+TestZeep.test_echo_date_with_invalid_formatc                 C   r(   r   )r   r   timer   r   	echo_timer!   r   r   r   test_echo_timeM   r,   zTestZeep.test_echo_timec                 C   r(   r   )r   r   r/   r   r   echo_time_with_invalid_formatr!   r   r   r   "test_echo_time_with_invalid_formatS   r,   z+TestZeep.test_echo_time_with_invalid_formatc                 C   s&   g d}| j j|}||ksJ d S )N)FFFT)r   r   echo_simple_boolean_arrayr!   r   r   r   test_echo_simple_boolean_arrayY   r%   z'TestZeep.test_echo_simple_boolean_arrayc                 C   s@   d}| j j|}| || d}| j j|}| || d S )NTF)r   r   echo_booleanassertEqualr!   r   r   r   test_echo_boolean_   s   zTestZeep.test_echo_booleanc                 C   s4   | j d| j d}| j j|}||ksJ d S )Nz{%s}DaysOfWeekEnumMonday)r   r   r   r   	echo_enumr!   r   r   r   	test_enumh   s   zTestZeep.test_enumc                 C   s"   d}| j j|}||ksJ d S )Ns    )r   r   echo_bytearrayr!   r   r   r   test_bytearrayo      zTestZeep.test_bytearrayc              
   C   sZ   | j d }d|_d |_z| j j| W td ty, } zW Y d }~d S d }~ww )N{hunk.sunk}NonNillableClass   	must fail)r   r   isr   non_nillable	ZeepError	Exception)r   non_nillable_classer   r   r   test_validationu   s   zTestZeep.test_validationc                 C   s6   | j d| j  }|jg d | j j| d S )N{%s}integerArray)               )r   r   r   integerextendr   echo_integer_array)r   iar   r   r   test_echo_integer_array   s   z TestZeep.test_echo_integer_arrayc                 C   sh   | j d| j  }d|_d|_| j jjd|id}t| |jj	}| 
|j|j | 
|j|j d S )N{%s}InHeaderarM   InHeader_soapheaders)r   r   r   rC   rB   r   echo_in_headerprintbodyecho_in_headerResultr7   )r   	in_headerr#   
out_headerr   r   r   test_echo_in_header   s   zTestZeep.test_echo_in_headerc              	   C   s   | j d| j  }d|_d|_| j d| j  }d|_ tdddddddd	|_| j jj||d
d}t	| |j
j}|j
j}| |j|j | |j|j | |j |j  | |j|j d S )NrU   rV   rM   z{%s}InTraceHeadersuds  rK   r   yearmonthdayhourminutesecondmicrosecond)rW   InTraceHeaderrX   )r   r   r   rC   rB   r   callDater   echo_in_complex_headerr[   r\   echo_in_complex_headerResult0echo_in_complex_headerResult1r7   )r   r^   in_trace_headerr#   r_   out_trace_headerr   r   r   test_echo_in_complex_header   s&   

z$TestZeep.test_echo_in_complex_headerc                 C   sb   | j d| j  }tdddd|_d|_| j j }| |j	j
j|j | |j	j
j|j d S )N{%s}OutHeaderrb   rK   rd   re   rf   8/T!	@)r   r   r   r   dtfr   send_out_headerr7   header	OutHeader)r   r_   r#   r   r   r   test_send_out_header   s   zTestZeep.test_send_out_headerc              	   C   s   | j d| j  }tdddd|_d|_| j d| j  }tdddddddd|_tdddddddd|_| j j	 }| 
|jjj|j | 
|jjj|j | 
|jjj|j | 
|jjj|j d S )	Nrs   rb   rK   rt   ru   z{%s}OutTraceHeaderrc   d   )r   r   r   r   rv   rw   receiptDate
returnDater   send_out_complex_headerr7   ry   rz   OutTraceHeader)r   r_   rq   r#   r   r   r   test_send_out_complex_header   s   z%TestZeep.test_send_out_complex_headerc                 C   s"   d}| j j|}| || d S )NOK)r   r   echo_stringr7   )r   test_stringr#   r   r   r   test_echo_string   r>   zTestZeep.test_echo_stringc                 C   s0   dddgiddgddgidd	gigg d
gdiS )Ntest_subtest_subsubsub1zsubsubsub1 valuezsubsub2 value 1zsubsub2 value 2test_subsub3sub1zsubsub3sub1 valuetest_subsub3sub2zsubsub3sub2 valuex)test_subsub1test_subsub2test_subsub3test_subsub4test_subsub5r   r   r   r   r   __get_xml_test_val   s   zTestZeep.__get_xml_test_valc                 C   sR   | j d| j  }d|_d|_| j j|}|j|jksJ |j|jks'J d S )N{%s}SimpleClass-   asd)r   r   r   rB   rC   r   echo_simple_classr!   r   r   r   test_echo_simple_class   s   zTestZeep.test_echo_simple_classc                 C   sv   | j d| j  }d|_| j d| j  |_d|j_d |j_| j j|}|j|jks/J |jj|jjks9J d S )Nz{%s}ClassWithSelfReferencer   2   )r   r   r   rB   srr   echo_class_with_self_referencer!   r   r   r   #test_echo_class_with_self_reference   s   z,TestZeep.test_echo_class_with_self_referencec                 C   s  | j d }d|_d|_d|_| j d| j  |_|jjg d | j d| j  |_	|j	j
| j d| j   |j	j
| j d| j   d|j	j
d	 _d|j	j
d	 _d
|j	j
d _d|j	j
d _| j d| j  |_t |j_d|j_d|j_| j j|}| |j|j | |jj|jj | |jjd	 |jjd	  | |j	j
d	 j|j	j
d	 j | |jj|jj d S )Nz{punk.tunk}NestedClassr   r   Gz(@rJ   )	rK   rL   rM   r   rO   rM   rL   rK   rN   {%s}SimpleClassArrayr   r      rK   qwe{%s}OtherClassw/^@T)r   r   rB   rC   rw   r   airP   rQ   simpleSimpleClassappendotherr   r   rv   dbr   echo_nested_classr7   r!   r   r   r   test_echo_nested_class   s.    zTestZeep.test_echo_nested_classc                 C   s    |  | jj dtd  d S )NrL   g     j@)r7   r   r   huge_numberintr   r   r   r   test_huge_number  s    zTestZeep.test_huge_numberc                 C   s   |  | jj dd  d S )N0123456789abcdefi @  )r7   r   r   long_stringr   r   r   r   test_long_string  s   zTestZeep.test_long_stringc                 C   s   | j j  d S r   )r   r   
test_emptyr   r   r   r   r   "  s   zTestZeep.test_emptyc                 C   s  | j d }d|_d|_d|_| j d| j  |_|jj| j d| j   |jj| j d| j   d|jjd _d|jjd _d|jjd	 _d
|jjd	 _| j d| j  |_	t
 |j	_d|j	_d|j	_| j d |_t
ddd|j_d|j_d|j_t
ddd|_d|_| j j|}t| | |j|j | |j|j | |j|j | |jjd j|jjd j | |j	j|j	j | |jj|jj d S )Nz{bar}ExtensionClassr   r   r   r   r   r   r   rK   r   r   r   Tr?   i  r@   rL   {   punk   rO   )r   r   rB   rC   rw   r   r   r   r   r   r   r   rv   r   r   plqr   echo_extension_classr[   r7   r!   r   r   r   test_echo_extension_class%  s:    z"TestZeep.test_echo_extension_classc              
   C   <   z
| j j  td ty } zW Y d }~d S d }~ww NrA   )r   r   python_exceptionrF   rE   r   rH   r   r   r   test_python_exceptionN     zTestZeep.test_python_exceptionc              
   C   r   r   )r   r   soap_exceptionrF   rE   r   r   r   r   test_soap_exceptionU  r   zTestZeep.test_soap_exceptionc                 C   sN   | j j }| |jd | |jd | |jd | |jjd d d S )NrK   Testr   r   MEMBER)	r   r   complex_returnr7   
resultCoderesultDescriptiontransactionIdrolesRoleEnumr   r#   r   r   r   test_complex_return\  s
   zTestZeep.test_complex_returnc                 C   s"   z
| j j  td   Y d S r   )r   r   return_invalid_datarF   r   r   r   r   test_return_invalid_datad  s
   z!TestZeep.test_return_invalid_datac                 C      | j jd}|dksJ d S Ntest)r   r   custom_messagesr   r   r   r   test_custom_messagesk     zTestZeep.test_custom_messagesc                 C   r   r   )r   r   echo_simple_barer   r   r   r   test_echo_simple_barep  r   zTestZeep.test_echo_simple_barec                 C   s&   ddg}| j j|}||ksJ d S )Nabcdef)r   r   echo_complex_barer!   r   r   r   test_echo_complex_bareu  r%   zTestZeep.test_echo_complex_bareN)%__name__
__module____qualname__r   r   r$   r'   r+   r.   r1   r3   r5   r8   r;   r=   rI   rT   r`   rr   r{   r   r   _TestZeep__get_xml_test_valr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   &   sF    	
 )r   __main__)logging	getLoggerzeep_loggersetLevelINFOunittestr   base64r   r   r   r   
spyne.utilr   r   r   zeep.transportsr	   zeep.exceptionsr
   rE   TestCaser   r   mainr   r   r   r   <module>   s"   
  W