
    i                         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)z0Tests for Story 1.02 (Track B): InterceptorChain    Nz/mnt/e/genesis-systemc                      ddl mm ddlm g  G fdd       G fdd       G fdd	      fd
} t        j                   |               t        d       y )Nr   )BaseInterceptorInterceptorMetadata)InterceptorChainc                   @    e Zd Z W  dd      ZfdZd Zd Zd Zy)	0test_interceptor_chain.<locals>.TestInterceptorAalpha
   namepriorityc                 <   K   j                  d       d|d<   |S w)NATr	   appendselfpexecution_orders     6/mnt/e/genesis-system/tests/track_b/test_story_1_02.pypre_executez<test_interceptor_chain.<locals>.TestInterceptorA.pre_execute   #     ""3'AgJH   c                    K   y wN r   rr   s      r   post_executez=test_interceptor_chain.<locals>.TestInterceptorA.post_execute           c                    K   ddiS w)Nhandlerr   r   r   er   s      r   on_errorz9test_interceptor_chain.<locals>.TestInterceptorA.on_error        	3/?(?   c                    K   |S wr   r   r   cs     r   on_correctionz>test_interceptor_chain.<locals>.TestInterceptorA.on_correction   
     (   N__name__
__module____qualname__metadatar   r   r&   r,   r   r   s   r   TestInterceptorAr      s    &GbA	 	1?2    r5   c                   @    e Zd Z W  dd      ZfdZd Zd Zd Zy)	0test_interceptor_chain.<locals>.TestInterceptorBbeta   r   c                 <   K   j                  d       d|d<   |S w)NBTr9   r   r   s     r   r   z<test_interceptor_chain.<locals>.TestInterceptorB.pre_execute   s#     ""3'AfIHr   c                    K   y wr   r   r   s      r   r   z=test_interceptor_chain.<locals>.TestInterceptorB.post_execute   r    r!   c                    K   ddiS w)Nr#   r<   r   r$   s      r   r&   z9test_interceptor_chain.<locals>.TestInterceptorB.on_error   r'   r(   c                    K   |S wr   r   r*   s     r   r,   z>test_interceptor_chain.<locals>.TestInterceptorB.on_correction    r-   r.   Nr/   r4   s   r   TestInterceptorBr8      s    &FQ?	 	1?2r6   r@   c                   B    e Zd Z W  ddd      ZfdZd Zd Zd Zy	)
0test_interceptor_chain.<locals>.TestInterceptorCgamma   F)r   r   enabledc                 <   K   j                  d       d|d<   |S w)NCTrC   r   r   s     r   r   z<test_interceptor_chain.<locals>.TestInterceptorC.pre_execute$   r   r   c                    K   y wr   r   r   s      r   r   z=test_interceptor_chain.<locals>.TestInterceptorC.post_execute(   r    r!   c                    K   ddiS w)Nr#   rG   r   r$   s      r   r&   z9test_interceptor_chain.<locals>.TestInterceptorC.on_error)   r'   r(   c                    K   |S wr   r   r*   s     r   r,   z>test_interceptor_chain.<locals>.TestInterceptorC.on_correction*   r-   r.   Nr/   r4   s   r   TestInterceptorCrB   "   s!    &Gb%P	 	1?2r6   rK   c                  F  K           } | j                                 | j                                 | j                                 j                          | j                  ddi       d {   }ddg}|k(  }|st        j                  d|fd|f      dt        j                         v st        j                        rt        j                        ndt        j                  |      dz  }t        j                  d	       d
z   d|iz  }t        t        j                  |            d x}}|d   }d}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|d   }d}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}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}}| j                         }
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}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|
d   d!   }d"}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|
d#   d$   }d%}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}| j                  D cg c]  }|j                  j                    }}t#        |      }||k(  }|s#t        j                  d|fd&||f      d't        j                         v st        j                  |      rt        j                  |      nd'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                  |      d)z  }d*d+|iz  }t        t        j                  |            d x}} G fd,d-      }        }|j                   |              |j                                 |j%                  d.diddi       d {    | j'                  t)        d/      i        d {   }|d0   }d}||k(  }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}| j+                  d      }d}||k(  }|st        j                  d|fd||f      d1t        j                         v st        j                  |      rt        j                  |      nd1t        j                  |      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d2t        j                         v st        j                  |       rt        j                  |       nd2t        j                  |      t        j                  |      dz  }	dd|	iz  }t        t        j                  |            d x}x}}| j+                  d3      }d%}||k(  }|st        j                  d|fd||f      d4t        j                         v st        j                  |      rt        j                  |      nd4t        j                  |      dz  }dd|iz  }t        t        j                  |            d x}}y 7 
c c}w 7 /7 w)5NstartTr<   r   )==)z%(py0)s == %(py3)sr   )py0py3zExpected ['B', 'A'], got z
>assert %(py5)spy5r9   )z%(py1)s == %(py4)s)py1py4zassert %(py6)spy6r	   rC   )not in)z%(py1)s not in %(py3)sresult)rR   rP   zassert %(py5)s   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)slensummary)rO   rR   rP   rT   zassert %(py8)spy8r   r   r   r:      rE   F)z0%(py0)s == %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
}
prioritiessorted)rO   py2rP   rQ   zassert %(py7)spy7c                   <    e Zd Z W  dd      Zd Zd Zd Zd Zy)	Etest_interceptor_chain.<locals>.run_tests.<locals>.RaisingInterceptorraiser   r   c                    K   |S wr   r   )r   r   s     r   r   zQtest_interceptor_chain.<locals>.run_tests.<locals>.RaisingInterceptor.pre_executeM   s
     1Hr.   c                     K   t        d      w)Nboom)RuntimeErrorr   s      r   r   zRtest_interceptor_chain.<locals>.run_tests.<locals>.RaisingInterceptor.post_executeN   s     l66J0Js   c                    K   i S wr   r   r$   s      r   r&   zNtest_interceptor_chain.<locals>.run_tests.<locals>.RaisingInterceptor.on_errorO   s
     2Ir.   c                    K   |S wr   r   r*   s     r   r,   zStest_interceptor_chain.<locals>.run_tests.<locals>.RaisingInterceptor.on_correctionP   s
     Qhr.   Nr/   )r   s   r   RaisingInterceptorra   K   s    *1EH4J56r6   rj   donetestr#   removedchainnonexistentremoved_again)registerclearexecute_pre
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_saferepr_format_assertmsgAssertionError_format_explanationget_chain_summaryrX   _interceptorsr3   r   r]   execute_postexecute_error
ValueError
unregister)rn   rV   @py_assert2@py_assert1@py_format4@py_format6@py_assert0@py_assert3@py_format5@py_format7rY   @py_assert5@py_assert4@py_format9ir\   @py_format8rj   chain2error_resultrm   rp   r   r   r   r5   r@   rK   r   s                         r   	run_testsz)test_interceptor_chain.<locals>.run_tests,   s     " 	')*')*')* 	(('499#&*[*,[[[*[[[[[[[[[[[[*[[[0I/IZ.[[[[[[[f~%%~%%%%~%%%~%%%%%%%%%%g&$&$&&&&$&&&&&&$&&&&&&&$wf$$$$wf$$$w$$$$$$f$$$f$$$$$$$ $wf$$$$wf$$$w$$$$$$f$$$f$$$$$$$ ))+7| q |q    |q      s   s      7   7   |   q       qz&!+V+!V++++!V+++!+++V+++++++qz*%**%****%***%**********qz)$--$----$---$---------- 493F3FGaajj))G
G#J//z/////z///////z///z//////V///V//////J///J///////////	7 	7 "#*,-(*+!!64.7D/BBB #00F1CRHHI&-#-&#----&#---&---#------- ""6*w$w$ww$5zQzQzQss55zQ((7 %%}%%%%}%%%%%%}%%%}%%%%%%%%%%Y :" H 	C IsE   A0l!3l4Wl!:lFl!,l-"l!lLl!l!l!u)   ALL TESTS PASSED — Story 1.02 (Track B))"core.interceptors.base_interceptorr   r   #core.interceptors.interceptor_chainr   asynciorunprint)r   r   r   r   r5   r@   rK   r   s    @@@@@@@r   test_interceptor_chainr      sX    WD O3? 33? 33? 36& 6&p KK		
56r6   __main__)__doc__builtinsrv   _pytest.assertion.rewrite	assertionrewritert   r   syspathinsertr   r0   r   r6   r   <module>r      sA    6    
 * +^7@ z r6   