
    ؄_                         d dl m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
 ddlmZ  G d dej                  Z G d de          ZdS )    )dequeN   )config)fixtures)	profiling   )create_engine)MetaData)util)Sessionc                   F    e Zd Zej        d             Zd Zd Zd Zd Z	dS )ReplayFixtureTestc              /      K   d V  d S N )selfargkws      f/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/testing/replay_fixture.py
_dummy_ctxzReplayFixtureTest._dummy_ctx   s          c                    t                      t          j        j        j        fd}t          t          j        j        |d          }t          |          | _        || _	        t          |          | _        |                                  	 |                     | j                   |                                  |                                 n-# |                                  |                                 w xY wfd}t          t          j        j        |d          }t          |          | _        || _	        t          |          | _        |                                  	 |                     t"          j                   | j                                         |                                 d S # | j                                         |                                 w xY w)Nc                  >                                                 S r   )recorder)creatordbapi_sessions   r   r   z3ReplayFixtureTest.test_invocation.<locals>.recorder   s     ))''))444r   F)r   use_native_hstore)ctxc                  ,                                      S r   )player)r   s   r   r    z1ReplayFixtureTest.test_invocation.<locals>.player)   s     '')))r   )ReplayableSessionr   dbpool_creatorr	   urlr
   metadataenginer   sessionsetup_engine
_run_stepsr   teardown_enginedisposer   count_functionsclose)r   r   r'   r    r   r   s       @@r   test_invocationz!ReplayFixtureTest.test_invocation   s   )++).)	5 	5 	5 	5 	5 	5 IM8u
 
 
 !((v	OOO000  """NN   """NN	* 	* 	* 	* 	* IM6U
 
 
 !((v	OO	 9O:::L   NN L   NNs   C *D - F< </G+c                     d S r   r   r   s    r   r)   zReplayFixtureTest.setup_engine;       r   c                     d S r   r   r1   s    r   r+   z!ReplayFixtureTest.teardown_engine>   r2   r   c                     t                      r   )NotImplementedError)r   r   s     r   r*   zReplayFixtureTest._run_stepsA   s    !###r   N)
__name__
__module____qualname__
contextlibcontextmanagerr   r/   r)   r+   r*   r   r   r   r   r      sn          & & &P    $ $ $ $ $r   r   c                      e Zd ZdZ e            Z e            Zej        r< e	d  e
e          D                                           d dD                       Znj e	d  e
e          D                                           d e                                D                                           d dD                       Zd	 Zd
 Zd Z G d de          Z G d de          ZdS )r!   a  A simple record/playback tool.

    This is *not* a mock testing class.  It only records a session for later
    playback and makes no assertions on call consistency whatsoever.  It's
    unlikely to be suitable for anything other than DB-API recording.

    c                 b    g | ],}|                     d           t          t          |          -S _
startswithgetattrtypes.0ts     r   
<listcomp>zReplayableSession.<listcomp>S   s3    LLL1!,,s:K:KLWUALLLr   c                 8    g | ]}t          t          |          S r   rA   rB   rC   s     r   rF   zReplayableSession.<listcomp>U   s2     
 
 
 q!!
 
 
r   )FunctionTypeBuiltinFunctionType
MethodTypeBuiltinMethodType
LambdaTypeUnboundMethodTypec                 b    g | ],}|                     d           t          t          |          -S r=   r?   rC   s     r   rF   zReplayableSession.<listcomp>d   sD       <<,,E1%%  r   c                 Z    g | ](}t          |t                    st          |          n|)S r   )
isinstancetyperC   s     r   rF   zReplayableSession.<listcomp>k   sA        $.a#6#6=DGGGA  r   c                 8    g | ]}t          t          |          S r   rH   rC   s     r   rF   zReplayableSession.<listcomp>q   s2     	 	 	 E1%%	 	 	r   )rI   rJ   rK   rL   rM   c                 ,    t                      | _        d S r   )r   bufferr1   s    r   __init__zReplayableSession.__init__~   s    ggr   c                 8    |                      | j        |          S r   )RecorderrU   )r   bases     r   r   zReplayableSession.recorder   s    }}T[$///r   c                 6    |                      | j                  S r   )PlayerrU   r1   s    r   r    zReplayableSession.player   s    {{4;'''r   c                   6    e Zd Zd Zd Zed             Zd ZdS )ReplayableSession.Recorderc                 "    || _         || _        d S r   )_buffer_subject)r   rU   subjects      r   rV   z#ReplayableSession.Recorder.__init__   s    !DL#DMMMr   c                 
     fddD             \  }} ||i |}t          |          t          j        vr8|                    t          j                    t                     ||          S |                    |           |S )Nc                 F    g | ]}t                               |          S r   object__getattribute__rD   xr   s     r   rF   z7ReplayableSession.Recorder.__call__.<locals>.<listcomp>   9        ''a00  r   r`   r_   )rR   r!   NativesappendCallable)r   argsr   ra   rU   results   `     r   __call__z#ReplayableSession.Recorder.__call__   s       0  OGV
 Wd)b))FF||#4#<<</8999!tDzz&&111f%%%r   c                     | j         S r   )r`   r1   s    r   _sqla_unwrapz'ReplayableSession.Recorder._sqla_unwrap   s
    = r   c                     	 t                                |          S # t          $ r Y nw xY w fddD             \  }}	 t          |                              ||          }t          |          t          j        vr8|                    t          j                    t                     ||          S |                    |           |S # t          $ r! |                    t          j                    w xY w)Nc                 F    g | ]}t                               |          S r   rd   rg   s     r   rF   z?ReplayableSession.Recorder.__getattribute__.<locals>.<listcomp>   ri   r   rj   )	re   rf   AttributeErrorrR   r!   rk   rl   rm   NoAttribute)r   keyra   rU   ro   s   `    r   rf   z+ReplayableSession.Recorder.__getattribute__   s   ..tS999!      0  OGV"g77EE
 <<'8'@@@MM"3"<===%4::ff555MM&)))!M "   /;<<<s    
++ #C +C8Nr6   r7   r8   rV   rp   propertyrr   rf   r   r   r   rX   r]      s\        	$ 	$ 	$	 	 	 
	! 	! 
	!	" 	" 	" 	" 	"r   rX   c                   6    e Zd Zd Zd Zed             Zd ZdS )ReplayableSession.Playerc                     || _         d S r   )r_   )r   rU   s     r   rV   z!ReplayableSession.Player.__init__   s    !DLLLr   c                     t                               | d          }|                                }|t          j        u r| S |S Nr_   )re   rf   popleftr!   rm   )r   rn   r   rU   ro   s        r   rp   z!ReplayableSession.Player.__call__   s?    ,,T9==F^^%%F*333r   c                     d S r   r   r1   s    r   rr   z%ReplayableSession.Player._sqla_unwrap   s    4r   c                    	 t                               | |          S # t          $ r Y nw xY wt                               | d          }|                                }|t          j        u r| S |t          j        u rt          |          |S r~   )re   rf   ru   r   r!   rm   rv   )r   rw   rU   ro   s       r   rf   z)ReplayableSession.Player.__getattribute__   s    ..tS999!   ,,T9==F^^%%F*333,888$S)))s    
**Nrx   r   r   r   r[   r{      s\        	" 	" 	"	 	 	 
	 	 
		 	 	 	 	r   r[   N)r6   r7   r8   __doc__re   rm   rv   r   py2ksetdirrB   
differencerk   union__builtins__valuesrV   r   r    rX   r[   r   r   r   r!   r!   E   s         vxxH&((Ky +
#LLE

LLL
 

*
 

 
 

 
 	" C  SZZ    U )0022    Z	 		 	 	  	8  0 0 0( ( (," ," ," ," ,"6 ," ," ,"\         r   r!   )collectionsr   r9   rB    r   r   r   r	   r
   r   ormr   TestBaser   re   r!   r   r   r   <module>r      s                                                       4$ 4$ 4$ 4$ 4$) 4$ 4$ 4$nL L L L L L L L L Lr   