o
    i                     @   sV  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl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 d dlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d d	l)m*Z* d d
l+m,Z, dZ-G dd dej.Z/G dd dej.Z0G dd deZ1G dd dej.Z2e3dkre4  dS dS )    )print_functionN)	timedelta)etree)re_match_with_span)six)xml)NullAnyDictUuidArrayComplexModelDateTimeBooleanDateTimeDurationFloatIntegerNumberLimitsWarningUnicodeStringDecimal	Integer16	ModelBaseMimeTypeMimeTypeStrict	MediaType)ProtocolBase)XmlDocumenttest_namespacec                   @      e Zd ZdS )TestCastN__name__
__module____qualname__ r&   r&   _/var/www/html/LicenciasMIG/venv/lib/python3.10/site-packages/spyne/test/model/test_primitive.pyr!   2       r!   c                   @   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$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6didj Z7dkdl Z8dmdn Z9dodp Z:dqdr Z;dsdt Z<duS )vTestPrimitivec                 C   s  t j}tj}t|dsJ t|drJ t|drJ t|ds"J t|dr)J t|dr0J tj}tj}t|j t|dsBJ t|drIJ t|dsPJ t|d	sWJ t|d
s^J t|dseJ t|dslJ t|dssJ t|dszJ t|drJ t|drJ t|dsJ t|dsJ t|dsJ t|dsJ t|drJ t|drJ t|drJ t|drJ t|drJ t|drJ t|drJ tsJ d S )Nzapplication/foozapplication/ foozapplication/zfoo/barzfoo/bar z
text/plainz text/plainztext/plain;ztext/plain;charset=utf-8ztext/plain; charset="utf-8"ztext/plain; charset=utf-8ztext/plain; charset=utf-8 ztext/plain; charset=utf-8;ztext/plain; charset=utf-8; ztext/plain; charset=utf-8; fooztext/plain; charset=utf-8; foo=z!text/plain; charset=utf-8; foo=""z"text/plain; charset=utf-8; foo="";z#text/plain; charset=utf-8; foo=""; z$text/plain; charset=utf-8; foo="";  z"text/plain;; charset=utf-8; foo=""z#text/plain;;; charset=utf-8; foo=""z"text/plain; charset=utf-8;; foo=""z#text/plain; charset=utf-8;;; foo=""z$text/plain; charset=utf-8;;; foo="";z'text/plain; charset=utf-8;;; foo=""; ; z applicaton/json;)r   
Attributesr   rmwsr   printpattern)self	mime_attrmime_strict_attr
media_attrmedia_strict_attrr&   r&   r'   test_mime_type_family7   sD   
z#TestPrimitive.test_mime_type_familyc                 C   s   t tdd jjsJ d S )N   max_len)r   dictr*   r6   r.   r&   r&   r'   test_getitem_custa   s   zTestPrimitive.test_getitem_custc                 C   sj   G dd dt }G dd d|}G dd d|}| ||gks"J | |gks+J | g ks3J d S )Nc                   @      e Zd ZeZdS )z'TestPrimitive.test_ancestors.<locals>.AN)r#   r$   r%   r   ir&   r&   r&   r'   Ae       r<   c                   @   r:   )z'TestPrimitive.test_ancestors.<locals>.BN)r#   r$   r%   r   i2r&   r&   r&   r'   Bf   r=   r?   c                   @   r:   )z'TestPrimitive.test_ancestors.<locals>.CN)r#   r$   r%   r   i3r&   r&   r&   r'   Cg   r=   rA   )r   	ancestors)r.   r<   r?   rA   r&   r&   r'   test_ancestorsd   s   zTestPrimitive.test_ancestorsc                 C   s*  t jjdksJ G dd dt j}|jdksJ |jdksJ G dd dt j}|jdks/J |jdks6J G dd dt j}|jdksFJ |jdksMJ G dd dt j}|jdks]J |jdksdJ G dd dt j}|jdkstJ |jdks{J G d	d dt j}G d
d d|}|jdksJ d S )NTc                   @   s   e Zd ZdZdZdS 6TestPrimitive.test_nillable_quirks.<locals>.AttributesFN)r#   r$   r%   nillablenullabler&   r&   r&   r'   r*   p   s    r*   Fc                   @      e Zd ZdZdS rE   TNr#   r$   r%   rF   r&   r&   r&   r'   r*   w       c                   @   rH   rD   rJ   r&   r&   r&   r'   r*   }   rK   c                   @   rH   rI   r#   r$   r%   rG   r&   r&   r&   r'   r*      rK   c                   @   rH   rD   rL   r&   r&   r&   r'   r*      rK   c                   @   rH   rD   rL   r&   r&   r&   r'   r*      rK   c                   @   r    )rE   Nr"   r&   r&   r&   r'   r*      r(   )r   r*   rF   rG   )r.   r*   r&   r&   r'   test_nillable_quirksm   s&   z"TestPrimitive.test_nillable_quirksc                 C   sr   G dd dt j}G dd d}G dd d||}|jdu s J G dd d}G d	d d||}|jdu s7J d S )
Nc                   @   rH   )zBTestPrimitive.test_nillable_inheritance_quirks.<locals>.AttributesFNrL   r&   r&   r&   r'   r*      rK   r*   c                   @   r    zATestPrimitive.test_nillable_inheritance_quirks.<locals>.AttrMixinNr"   r&   r&   r&   r'   	AttrMixin   r(   rO   c                   @   r    zETestPrimitive.test_nillable_inheritance_quirks.<locals>.NewAttributesNr"   r&   r&   r&   r'   NewAttributes   r(   rQ   Fc                   @   r    rN   r"   r&   r&   r&   r'   rO      r(   c                   @   r    rP   r"   r&   r&   r&   r'   rQ      r(   )r   r*   rG   )r.   r*   rO   rQ   r&   r&   r'    test_nillable_inheritance_quirks   s   z.TestPrimitive.test_nillable_inheritance_quirksc                 C   s0   t ddjjdksJ t ddjjdksJ d S )N
      )r   r*   total_digitsfraction_digitsr8   r&   r&   r'   test_decimal      zTestPrimitive.test_decimalc                 C   sF   d}d}t d}t d t|d||t |d }| |jd d S )Ni@ z${0}test)
str_formatr   z$123456)r   Elementr   	to_parentr   ns_testassertEqualtext)r.   frZ   elementr&   r&   r'   test_decimal_format   s   
z!TestPrimitive.test_decimal_formatc                 C   sZ   t  }td}t d t d|t |d }| |jd t d t |}| |d d S )NrY   valuer   )	r   r   r[   r   r\   r]   r^   r_   from_elementr.   sra   rc   r&   r&   r'   test_string   s   
zTestPrimitive.test_stringc                 C   sf   t j tj}td}t d t||t	 |d }| 
|j|  t d t|}| 
|| d S )NrY   r   )datetimenowpytzutcr   r[   r   r\   r   r]   r^   r_   	isoformatrd   )r.   nra   dtr&   r&   r'   test_datetime   s   
zTestPrimitive.test_datetimec                 C   s   t j  jdd}d}td}t d t|d||t |d }|j	t j 
||ks-J t d t|d|}||ks>J d S )Nr   microsecondz%Y %m %d %H %M %SrY   	dt_format)rh   ri   replacer   r[   r   r\   r   r]   r_   strftimerd   r.   rm   formatra   rn   r&   r&   r'   test_datetime_format   s   
z"TestPrimitive.test_datetime_formatc                 C   s   t j  jdd}d}td}t d t|d||t |d }t	j
r5|j||ddks4J n
|j||ks?J t d t|d|}||ksPJ d S )Nr   rp   u   %Y %m %d %H %M %SrY   rr   utf8)rh   ri   rt   r   r[   r   r\   r   r]   r   PY2r_   ru   encodedecoderd   rv   r&   r&   r'   test_datetime_unicode_format   s    

z*TestPrimitive.test_datetime_unicode_formatc                 C   sx   t j }d}td}t d t|d||t |d j	t j
||ks'J t d t|d|d }||ks:J d S )Nz%Y-%m-%drY   )date_formatr   )rh   datetodayr   r[   r   r\   r   r]   r_   ru   rd   )r.   trw   ra   rn   r&   r&   r'   test_date_format   s   

zTestPrimitive.test_date_formatc                 C   s   dd l }tj|d}td}t|jdd}t 	d |||t
 |d }||jjd d}| |j|  t d ||}|jd usIJ |jd d}| || d S )Nr   ESTrY   F)as_timezonetimezonetzinfo)rj   rh   ri   r   r   r[   r   rk   r   r\   r]   
astimezonert   r^   r_   rl   rd   r   )r.   rj   rm   ra   clscrn   r&   r&   r'   test_datetime_timezone   s   
z$TestPrimitive.test_datetime_timezonec                 C   sH   t d}d|_t d t|}td tddd t|}t| d S )Nwotz2013-08-09+02:00zok without validation.soft)	validator)r   r[   r_   r   rd   r   r,   )r.   eltrn   r&   r&   r'   test_date_timezone  s   
z TestPrimitive.test_date_timezonec                 C   sL   t dddd}t t|}| ||  t t|}| || d S )N   r4      rT   )rh   timer   to_bytesr   r^   rl   from_unicoder.   rm   retrn   r&   r&   r'   	test_time  s
   zTestPrimitive.test_timec                 C   s   t  td}| tddd| t  td}| tdddd| t  td}| tdddd| t  td}| tdddd| t  td}| tdddd| d S )	Nz12:12:12.0000001   z12:12:12.0000015r4   z12:12:12.9999988?B z12:12:12.9999991z12:12:12.9999998)r   r   r   r^   rh   r   )r.   r   r&   r&   r'   test_time_usec  s   zTestPrimitive.test_time_usecc                 C   sJ   t ddd}t t|}| ||  t t|}| || d S )Ni  r      )rh   r   r   
to_unicoder   r^   rl   r   r   r&   r&   r'   	test_date9  s
   zTestPrimitive.test_datec                 C   s   d}t d}||_t d t|}| |jd | |jd | |j	d d}t d}||_t d t|}| |jd | |jd | |j	d d S )Nz2007-05-15T13:40:44ZrY   i        z2007-05-15T13:40:44.003Z)
r   r[   r_   r   rd   r   r^   yearmonthday)r.   
datestringern   r&   r&   r'   test_utcdatetimeB  s   

zTestPrimitive.test_utcdatetimec              
   C   ^   t jtdddtdddd}| ||tddd | ||tddd d S )N  r   r4   gtlt)r   	customizerh   r   assertFalsevalidate_nativer.   
test_modelr&   r&   r'   test_date_exclusive_boundariesW     z,TestPrimitive.test_date_exclusive_boundariesc              
   C   r   )Nr   r   r4   gele)r   r   rh   r   
assertTruer   r   r&   r&   r'   test_date_inclusive_boundaries_  r   z,TestPrimitive.test_date_inclusive_boundariesc                 C      t jtdddddjtjdtdddddjtjdd}| ||tddddd | ||tddddd d S )Nr   r   r   r   r   r4   r   )r   r   rh   rt   spyneLOCAL_TZr   r   r   r&   r&   r'   "test_datetime_exclusive_boundariesg  s   


z0TestPrimitive.test_datetime_exclusive_boundariesc                 C   r   )Nr   r   r   r   r   r4   r   )r   r   rh   rt   r   r   r   r   r   r&   r&   r'   "test_datetime_inclusive_boundariess  s   


z0TestPrimitive.test_datetime_inclusive_boundariesc              	   C   V   t jtddtddd}| ||tdd | ||tdd d S )Nr   r   r   r   )r   r   rh   r   r   r   r   r&   r&   r'   test_time_exclusive_boundaries     
z,TestPrimitive.test_time_exclusive_boundariesc              	   C   r   )Nr   r   r   r   )r   r   rh   r   r   r   r   r&   r&   r'   test_time_inclusive_boundaries  r   z,TestPrimitive.test_time_inclusive_boundariesc                 C   s0   |  tttjj |  tttjj d S N)r   r   r   rh   minmaxr8   r&   r&   r'   test_datetime_extreme_boundary  s   z,TestPrimitive.test_datetime_extreme_boundaryc                 C   s@   |  tttdddd |  tttdddd d S )Nr      ;   r   )r   r   r   rh   r   r8   r&   r&   r'   test_time_extreme_boundary  s   z(TestPrimitive.test_time_extreme_boundaryc                 C   s0   |  tttjj |  tttjj d S r   )r   r   r   rh   r   r   r   r8   r&   r&   r'   test_date_extreme_boundary  rX   z(TestPrimitive.test_date_extreme_boundaryc                 C   ^   d}t  }td}t d t ||t |d }| |jd t d ||}| || d S )Nr   rY   r   12	r   r   r[   r   r\   r]   r^   r_   rd   r.   r;   integerra   rc   r&   r&   r'   test_integer     
zTestPrimitive.test_integerc                 C   sz  t jdd<}t d tdd}t|dksJ tdd}t|dks&J t|d	 jts0J d
t|d	 j	v s;J W d    n1 sEw   Y  t jdd<}t d tdd}t|dkscJ tdd}t|dkspJ t|d	 jtszJ dt|d	 j	v sJ W d    n1 sw   Y  z
tdd W td t
y   Y nw z
tdd W td t
y   Y d S w )NT)recordalwaysi )r   r   ir   zsmaller than min_boundi  )r   i   zgreater than max_boundz	must fail)r   )warningscatch_warningssimplefilterr   len
issubclasscategoryr   strmessage
ValueError	Exception)r.   wr   r&   r&   r'   test_integer_limits  s<   





z!TestPrimitive.test_integer_limitsc                 C   r   )Nl   )Q,S rY   r   128375873458473r   r   r&   r&   r'   test_large_integer  r   z TestPrimitive.test_large_integerc                 C   s\   d}t d}t d t||t |d }| |jt| t 	d t|}| || d S )Ng8$Z?rY   r   )
r   r[   r   r\   r   r]   r^   r_   reprrd   )r.   r`   ra   f2r&   r&   r'   
test_float  s   
zTestPrimitive.test_floatc                 C   s   t t}||d g d}td}t d |||t |d }| t	|t	|
  t d ||}| |d |d  d S )Nzbank)abr   dr   r`   rY   r   r   r   r   resolve_namespacer   r[   r   r\   r]   r^   r   getchildrenrd   r.   typevaluesra   values2r&   r&   r'   
test_array  s   
zTestPrimitive.test_arrayc                 C   sz   t t}||d g }td}t d |||t |d }| t	|t	|
  t d ||}| t	|d d S )Nr   rY   r   r   r   r&   r&   r'   test_array_empty  s   
zTestPrimitive.test_array_emptyc                 C   sZ   d}|  dt| td}t d t||d |d }t d t|}|  || d S )N4Ue4rT   rY   test_nsr   )r^   r   r   r[   r   r\   r   rd   re   r&   r&   r'   test_unicode
  s   
zTestPrimitive.test_unicodec                 C   4   t ddjjdksJ t dddjjdksJ d S )Nr   r-   r   )r   r*   r-   r8   r&   r&   r'   test_unicode_pattern_mult_cust     z,TestPrimitive.test_unicode_pattern_mult_custc                 C   sX   d}t |dj}|j|ksJ |jjtj@ sJ |jds J |jdd u s*J d S )Nz[\w .-]+)unicode_patternu   Ğ Ğ ç .-	)r   r*   r-   _pattern_reflagsreUNICODEmatch)r.   pattattrr&   r&   r'   test_unicode_upattern  s   z#TestPrimitive.test_unicode_upatternc                 C   r   )NFrG   r   r   r*   rG   r8   r&   r&   r'   %test_unicode_nullable_mult_cust_false  r   z3TestPrimitive.test_unicode_nullable_mult_cust_falsec                 C   r   )NTr  r   r  r8   r&   r&   r'   $test_unicode_nullable_mult_cust_true#  r   z2TestPrimitive.test_unicode_nullable_mult_cust_truec                 C   sp   t d}t d td |t tt | |d }| t	|j
td t d t|}| d | d S )NrY   r   nil)r   r[   r   r\   r   r]   r,   tostringr   boolattribgetnsXSIrd   r^   )r.   ra   rc   r&   r&   r'   	test_null'  s   
zTestPrimitive.test_nullc                 C   sf   ddl m} t|d}|dd usJ |dd usJ |dd us(J |dd us1J d S )Nr   )_get_point_patternr4   zPOINT (10 40)zPOINT(10 40)zPOINT(10.0 40)zPOINT(1.310e4 40))spyne.model.primitive.spatialr  r   compiler   )r.   r  r   r&   r&   r'   
test_point1  s   zTestPrimitive.test_pointc                 C   0   ddl m} t|d}|dd usJ d S )Nr   )_get_multipoint_patternr4   z'MULTIPOINT (10 40, 40 30, 20 20, 30 10))r  r  r   r  r   )r.   r  r   r&   r&   r'   test_multipoint;     zTestPrimitive.test_multipointc                 C   r  )Nr   )_get_linestring_patternr4   z LINESTRING (30 10, 10 30, 40 40))r  r  r   r  r   )r.   r  r   r&   r&   r'   test_linestringC  r  zTestPrimitive.test_linestringc                 C   r  )Nr   )_get_multilinestring_patternr4   zeMULTILINESTRING ((10 10, 20 20, 10 40),
                                (40 40, 30 30, 40 20, 30 10)))r  r  r   r  r   )r.   r  r   r&   r&   r'   test_multilinestringI  s
   z"TestPrimitive.test_multilinestringc                 C   r  )Nr   )_get_polygon_patternr4   z-POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10)))r  r  r   r  r   )r.   r  r   r&   r&   r'   test_polygonP  s   zTestPrimitive.test_polygonc                 C   sB   ddl m} t|d}|dd usJ |dd usJ d S )Nr   )_get_multipolygon_patternr4   zmMULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),
                            ((15 5, 40 10, 10 20, 5 10, 15 5)))zMULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),
                                ((20 35, 45 20, 30 5, 10 10, 10 30, 20 35),
                                (30 20, 20 25, 20 15, 30 20))))r  r  r   r  r   )r.   r  r   r&   r&   r'   test_multipolygonW  s   zTestPrimitive.test_multipolygonc                 C   sf  t d}t d td|t |d }| d|j t d}t d td|t |d }| d|j t d}t d td|t |d }| d|j t d t|}| |d t d}t d td|t |d }| d|j t d t|}| |d t d}t d td |t |d }| d|	t
d t d t|}| |d  d S )	NrY   Tr   truefalser   Fr  )r   r[   r   r\   r   r]   r^   r_   rd   r
  r  r  )r.   r   r&   r&   r'   test_booleana  s4   




zTestPrimitive.test_booleanc                 C   s    t dd}| | |j dS )z=Customized primitives go into namespace based on module name.123r   N)r   r^   get_namespacer$   )r.   custom_typer&   r&   r'   test_new_type  s   
zTestPrimitive.test_new_typec              
   C   st   z,|  tjj tjj}dtj_| tjj | tjj W |tj_| tjj| dS |tj_| tjj| w )z4Test if default nullable changes nullable attribute.FN)r   r   r*   rG   NULLABLE_DEFAULTr   rF   r^   )r.   orig_defaultr&   r&   r'   test_default_nullable  s   z#TestPrimitive.test_default_nullablec                 C   s.   t ddjd us
J t jddjd usJ d S )Nr   r5   )r   __extends__r   r8   r&   r&   r'   'test_simple_type_explicit_customization  s   z5TestPrimitive.test_simple_type_explicit_customizationc                 C   s*   ddl m} ttjddjj|sJ d S )Nr   )jsonr*  )store_as)spyne.modelr*  
isinstancer	   r   r*   r+  )r.   r*  r&   r&   r'   test_anydict_customization  s   z(TestPrimitive.test_anydict_customizationc                 C   s   t d}t t|dksJ t tdd|dksJ t tdd|dks,J t tdd|dks:J t td	d|d
ksHJ t tdd|dksVJ t tdd|dksdJ d S N 12345678123456781234567812345678$12345678-1234-5678-1234-567812345678hexserialize_asurnz-urn:uuid:12345678-1234-5678-1234-567812345678bytess   4Vx4Vx4Vx4Vxbytes_les   xV44xV4Vx4Vxfields)ixV4i4  ixV     4   l   xVh$Y intl	   xVh$YgF+ )uuidUUIDr   r   r
   r.   rc   r&   r&   r'   test_uuid_serialize  s,   
z!TestPrimitive.test_uuid_serializec                 C   s   t d}t td|ksJ t tddd|ksJ t tddd|ks,J t tddd|ks:J t td	dd
|ksHJ t tddd|ksVJ t tddd|ksdJ d S r/  )r<  r=  r   r   r
   
from_bytesr>  r&   r&   r'   test_uuid_deserialize  sH   
z#TestPrimitive.test_uuid_deserializec                 C   s*   t t dsJ t t tdsJ d S )Nr1  )r
   validate_stringr   r<  r=  r8   r&   r&   r'   test_uuid_validate  s   z TestPrimitive.test_uuid_validatec                 C   s   d}t j |d }t tdd||d ksJ t tdd||d ks*J t tdd||d ks:J t tdd||d ksJJ t td	d||ksXJ d S )
N   :yT#     .Asecr3  	sec_floatmsec     @@
msec_floatusec)rh   fromtimestampr   r   r   r.   r;   vr&   r&   r'   test_datetime_serialize_as  s6   




z(TestPrimitive.test_datetime_serialize_asc                 C   s   d}t j |d }t tdd|d t j |d ks J t tdd|d |ks0J t tdd|d t j |d d ksHJ t td	d|d |ksXJ t td
d||ksfJ d S )NrD  rE  rF  r3  rG  rH  rI  i  rJ  rK  )rh   rL  r   r   r   rM  r&   r&   r'   test_datetime_deserialize  s6   
z'TestPrimitive.test_datetime_deserializec                 C   sT   t dd}tddd}d}t ||}| || t ||}| || d S )Nz%Y-%m-%d %H:%M:%Srr   iY  r   z1881-01-01 00:00:00)r   rh   r   r   r^   r   )r.   r   rN  vsrn   r&   r&   r'   test_datetime_ancient  s   
z#TestPrimitive.test_datetime_ancientc                 C   s2  t tdddd}|dkrt|td g }tddD ]}|td	d|d
 qi }tdD ]}||d  ||| < q4tddd}td	dd}t |d
}td}|| }	|	|k r|	j	dkry|	j
dkry|	jd dkrytd|	j t |	d
}
|| |
krtt|	|
}|	| }	|	|k sbd S d S )Ni  	   r   z%%Y has the same days as 1980 and 2008z'1800 has the same days as 1980 and 2008z6Testing all day names from 0001/01/01 until 2000/08/01r   rS   i  z%A   d   r   zTesting century)r   ru   rh   r   AssertionErrorr,   rangeappendr   r   r   r   r   )r.   rf   daysr;   nextday	startdateenddateprevdayone_daytestdater   r&   r&   r'   test_custom_strftime  s6   
z"TestPrimitive.test_custom_strftimec                 C   s   t  td}| tdddddd| t  td}| tddddddd| t  td}| tddddddd| t  td	}| tddddddd| t  td
}| tddddddd| d S )Nz2015-01-01 12:12:12.0000001i  r   r   z2015-01-01 12:12:12.0000015r4   z2015-01-01 12:12:12.9999988r   z2015-01-01 12:12:12.9999991z2015-01-01 12:12:12.9999998)r   r   r   r^   rh   )r.   rn   r&   r&   r'   test_datetime_usec  s(   "z TestPrimitive.test_datetime_usecN)=r#   r$   r%   r3   r9   rC   rM   rR   rW   rb   rg   ro   rx   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r   r$  r'  r)  r.  r?  rA  rC  rO  rP  rR  r`  ra  r&   r&   r&   r'   r)   6   sv    *	*

				'	


# r)   c                   @   s   e Zd ZdZe ZdS )SomeBlobmynsN)r#   r$   r%   __namespace__r   howlongr&   r&   r&   r'   rb  A  s    
rb  c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestDurationPrimitivec                 C   s   d}t  }tdddd|_td}t d t |||  |d }t|j ttj	|dd |d j
|ks9J |d|  j
}| || t d t |}|j |j ks]J d S )	NPT1H1M1Sr   )hoursminutessecondsrY   r   Tpretty_print{%s}howlongrb  r   re  r   r[   r   r\   r"  r,   r  r_   findr^   rd   total_secondsr.   answerggra   datas1r&   r&   r'    test_onehour_oneminute_onesecondG  s   

z6TestDurationPrimitive.test_onehour_oneminute_onesecondc              	   C   s  g d}|D ]Z\}}t  }t|d|_td}t d t |||  |d }t|j ttj	|dd |d j
|ks?J |d|  j
}| || t d t |}|j |ks`J q|D ]f\}}|dkr|d9 }d	| }t  }t|d|_td}t d t |||  |d }t|j ttj	|dd |d j
|ksJ |d|  j
}| || t d t |}|j |ksJ qcd S )
N)
)r   PT0S)r   PT1S)r   PT59S)<   PT1M)i  PT59M59S)i  PT1H)iQ PT23H59M59S)iQ P1D)i O P60D)i XP400Drj  rY   r   Trk  rm  r   -rn  )r.   tests_secondssecsrr  rs  ra   rt  ru  r&   r&   r'   test_4suiteY  sD   



z!TestDurationPrimitive.test_4suitec                 C      d}t  }tdd|_td}t d t |||  |d }t|j ttj	|dd |d j
|ks7J |d|  j
}| || t d t |}|j |j ks[J d S )	NPT35S#   r  rY   r   Trk  rm  rn  rq  r&   r&   r'   #test_duration_positive_seconds_only     

z9TestDurationPrimitive.test_duration_positive_seconds_onlyc                 C   s   d}t  }tddd|_td}t d t |||  |d }t|j ttj	|dd |d j
|ks8J |d	|  j
}| || t d t |}|j |j ks\J d S )
NPT5M35Sr   r  )ri  rj  rY   r   Trk  rm  rn  rq  r&   r&   r'   /test_duration_positive_minutes_and_seconds_only  s   

zETestDurationPrimitive.test_duration_positive_minutes_and_seconds_onlyc                 C   r  )	NzPT0.666000Si  )millisecondsrY   r   Trk  rm  rn  rq  r&   r&   r'   (test_duration_positive_milliseconds_only  r  z>TestDurationPrimitive.test_duration_positive_milliseconds_onlyc              
   C   sl   t jdddddd}d}d}| |t t| | |t t| | |t tt t| d S )Ni  r   r   g     j(A)rY  rh  ri  rj  microsecondszP400DT3672.8SzP1Y1M5DT1H1M12.8S)rh   r   r^   r   r   r   r   )r.   durstr1str2r&   r&   r'   test_duration_xml_duration  s   

z0TestDurationPrimitive.test_duration_xml_durationN)	r#   r$   r%   rv  r  r  r  r  r  r&   r&   r&   r'   rf  F  s    6rf  __main__)5
__future__r   r   r<  rh   unittestr   rj   r   r   lxmlr   spyne.model.primitive._baser   r+   
spyne.utilr   spyne.constr   r  r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   spyne.protocolr   spyne.protocol.xmlr   r]   TestCaser!   r)   rb  rf  r#   mainr&   r&   r&   r'   <module>   s>   \       