
    i5                         d Z ddlZddlmc mZ ddlZddlZej                  j                  dd       d Zedk(  r e        yy)z>Tests for Story 1.01 (Track B): BaseInterceptor Abstract Class    Nz/mnt/e/genesis-systemc                      ddl m} m 	  |        }d}|sNt        j                  d      dz   dt        j
                  |      iz  }t        t        j                  |            d } G fdd|       }	  |       }d}|sNt        j                  d	      dz   dt        j
                  |      iz  }t        t        j                  |            d } G fd
d|       } |       j                  }|j                  }d}	||	k(  }
|
st        j                  d|
fd||	f      dt        j                         v st        j                        rt        j
                        ndt        j
                  |      t        j
                  |      t        j
                  |	      dz  }dd|iz  }t        t        j                  |            d x}x}x}
}	j                  }|j                  }d}	||	k(  }
|
st        j                  d|
fd||	f      dt        j                         v st        j                        rt        j
                        ndt        j
                  |      t        j
                  |      t        j
                  |	      dz  }dd|iz  }t        t        j                  |            d x}x}x}
}	j                  }|j                   }d}	||	k(  }
|
st        j                  d|
fd||	f      dt        j                         v st        j                        rt        j
                        ndt        j
                  |      t        j
                  |      t        j
                  |	      dz  }dd|iz  }t        t        j                  |            d x}x}x}
}	| j"                  }d}||v }|st        j                  d|fd||f      t        j
                  |      dt        j                         v st        j                  |      rt        j
                  |      nddz  }dd|iz  }t        t        j                  |            d x}}d}||v }|st        j                  d|fd||f      t        j
                  |      dt        j                         v st        j                  |      rt        j
                  |      nddz  }dd|iz  }t        t        j                  |            d x}}d}||v }|st        j                  d|fd||f      t        j
                  |      dt        j                         v st        j                  |      rt        j
                  |      nddz  }dd|iz  }t        t        j                  |            d x}}d }||v }|st        j                  d|fd||f      t        j
                  |      dt        j                         v st        j                  |      rt        j
                  |      nddz  }dd|iz  }t        t        j                  |            d x}}t%        |      }d!}
||
k(  }|st        j                  d|fd"||
f      d#t        j                         v st        j                  t$              rt        j
                  t$              nd#dt        j                         v st        j                  |      rt        j
                  |      ndt        j
                  |      t        j
                  |
      d$z  }d%d&|iz  }t        t        j                  |            d x}x}}
 d'd(d)      }|j                  }d'}||k(  }|st        j                  d|fd*||f      d+t        j                         v st        j                  |      rt        j
                  |      nd+t        j
                  |      t        j
                  |      d,z  }d-d.|iz  }t        t        j                  |            d x}x}}|j                  }d(}||k(  }|st        j                  d|fd/||f      d+t        j                         v st        j                  |      rt        j
                  |      nd+t        j
                  |      t        j
                  |      d,z  }d-d.|iz  }t        t        j                  |            d x}x}}|j                   }d}||k(  }|st        j                  d|fd0||f      d+t        j                         v st        j                  |      rt        j
                  |      nd+t        j
                  |      t        j
                  |      d,z  }d-d.|iz  }t        t        j                  |            d x}x}}fd1}t'        j(                   |              t+        d2       y # t        $ r Y 	w xY w# t        $ r Y 	,w xY w)3Nr   )BaseInterceptorInterceptorMetadataFzShould have raised TypeErrorz
>assert %(py1)spy1c                   \    e Zd Z W  dd      ZdedefdZdededdfd	Zd
ededefdZy)1test_base_interceptor.<locals>.PartialInterceptorpartial2   nameprioritytask_payloadreturnc                    K   |S wN selfr   s     6/mnt/e/genesis-system/tests/track_b/test_story_1_01.pypre_executez=test_base_interceptor.<locals>.PartialInterceptor.pre_execute           resultNc                    K   y wr   r   r   r   r   s      r   post_executez>test_base_interceptor.<locals>.PartialInterceptor.post_execute   	        errorc                    K   i S wr   r   r   r   r   s      r   on_errorz:test_base_interceptor.<locals>.PartialInterceptor.on_error   s     Ir   )	__name__
__module____qualname__metadatadictr   r   	Exceptionr"   r   s   r   PartialInterceptorr      sV    &IC	 $ 	 4 	 	T 	 	$ 			 	 	$ 	    r*   z7Should have raised TypeError for partial implementationc                   l    e Zd Z W  dd      ZdedefdZdededdfd	Zd
ededefdZdedefdZ	y).test_base_interceptor.<locals>.FullInterceptorfullr
   r   r   r   c                    K   |S wr   r   r   s     r   r   z:test_base_interceptor.<locals>.FullInterceptor.pre_execute*   r   r   r   Nc                    K   y wr   r   r   s      r   r   z;test_base_interceptor.<locals>.FullInterceptor.post_execute-   r   r   r   c                 $   K   dt        |      iS w)Nr   )strr!   s      r   r"   z7test_base_interceptor.<locals>.FullInterceptor.on_error0   s     SZ((s   correction_payloadc                    K   |S wr   r   )r   r3   s     r   on_correctionz<test_base_interceptor.<locals>.FullInterceptor.on_correction3   s     %%r   )
r#   r$   r%   r&   r'   r   r   r(   r"   r5   r)   s   r   FullInterceptorr-   '   si    &FR@	 $ 	 4 	 	T 	 	$ 		)	 	) 	)$ 	)	&$ 	&4 	&r+   r6   r.   ==)zJ%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.metadata
}.name
} == %(py7)sf)py0py2py4py7zassert %(py9)spy9r
   )zN%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.metadata
}.priority
} == %(py7)sT)zM%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.metadata
}.enabled
} == %(py7)sr   inz%(py1)s in %(py3)sabstract_methodsr   py3assert %(py5)spy5r   r"   r5      )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)slen)r:   r   rD   py6zassert %(py8)spy8test
   )r   r   enabled)z,%(py2)s
{%(py2)s = %(py0)s.name
} == %(py5)smeta)r:   r;   rF   zassert %(py7)sr=   )z0%(py2)s
{%(py2)s = %(py0)s.priority
} == %(py5)s)z/%(py2)s
{%(py2)s = %(py0)s.enabled
} == %(py5)sc                     K   j                  ddi       d {   } ddi}| |k(  }|st        j                  d|fd| |f      dt        j                         v st        j
                  |       rt        j                  |       ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}j                  d	diddi       d {    j                  t        d      ddi       d {   }d
}||v }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j
                  |      rt        j                  |      nddz  }dd|iz  }t        t        j                  |            d x}}j                  ddi       d {   }ddi}||k(  }|st        j                  d|fd||f      dt        j                         v st        j
                  |      rt        j                  |      ndt        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}y 7 Y7 7 t7 w)NrK   Tr7   )z%(py0)s == %(py3)sr   )r:   rD   rE   rF   doner   r?   rA   error_resultrC   fixcorrection_result)r   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   r"   
ValueErrorr5   )	r   @py_assert2@py_assert1@py_format4@py_format6rQ   @py_assert0rS   r9   s	           r   test_methodsz+test_base_interceptor.<locals>.test_methodsJ   s    }}fd^44 $'v''''v''''''v'''v''''''''''nnfd^fd^<<<ZZ
6(:VTNKK&w,&&&&w,&&&w&&&&&&,&&&,&&&&&&&"#//5$-"@@%*DM1 M1111 M111111 111 111M1111111 5 	=K AsH   I>I3CI> I6!$I>I9B?I>I<B.I>6I>9I><I>u)   ALL TESTS PASSED — Story 1.01 (Track B))"core.interceptors.base_interceptorr   r   rT   _format_assertmsgrY   rZ   r[   	TypeErrorr&   r   rU   rV   rW   rX   r   rM   __abstractmethods__rH   asynciorunprint)r   bra   @py_format2r*   pr6   r^   @py_assert3@py_assert6@py_assert5@py_format8@py_format10rB   r]   r_   r`   @py_assert4@py_format7@py_format9rN   rb   r   r9   s                         @@r   test_base_interceptorru      s   W4u444444u44444

_ 
 OuOOOOOOuOOOOO
&/ & 	A::$:??$f$?f$$$$?f$$$$$$1$$$1$$$:$$$?$$$f$$$$$$$::$:$"$"$$$$"$$$$$$1$$$1$$$:$$$$$$"$$$$$$$::%:%%%%%%%%%%%%1%%%1%%%:%%%%%%%%%%%%% '::,=,,,,,=,,,,=,,,,,,,,,,,,,,,,,,->----->---->------------------):))))):)))):)))))))))))))))))).?.....?....?.................. %A% A%%%% A%%%%%%3%%%3%%%%%%%%%%%% %%%A%%%%%%% FRGD9999449==B=B=B44=B<< 5 <5    <5      4   4   <   5       
2 KK	
56S  (  s%   Ag  5Ag0  	g-,g-0	g=<g=__main__)__doc__builtinsrV   _pytest.assertion.rewrite	assertionrewriterT   rg   syspathinsertru   r#   r   r+   r   <module>r      sA    D    
 * +P7f z r+   