
    +h&                    "   U 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	 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 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 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$ ddl#m%Z%  e&       Z'de(d <    e
jR                  ed!      d"        Z*d# Z+e+Z,d$e(d%<   d&Z-d$e(d'<    G d( d)      Z. G d* d+      Z/ G d, d-e/      Z0 G d. d/e/      Z1y&)0    )annotations)Any)Dict)Set)CHAR)CheckConstraint)Column)event)
ForeignKey)Index)inspect)Integer)MetaData)Numeric)String)Table)Text)text)UniqueConstraint   )autogenerate)util)api)_fk_spec)MigrationContextops)config)eq_)clear_staging_env)staging_envzSet[Any]names_in_this_testafter_parent_attachc                B    t         j                  | j                         y N)r"   addname)tableparents     Z/var/www/html/venv/lib/python3.12/site-packages/alembic/testing/suite/_autogen_fixtures.py	new_tabler+   %   s    5::&    c                    |dk(  r|t         v S y)Nr(   T)r"   )objr'   type_	reflected
compare_tos        r*   _default_include_objectr2   *   s    )))r,   r   _default_object_filtersN_default_name_filtersc                  @    e Zd ZU dZdZded<   ed        Zed        Zy)ModelOne)unique_constraint_reflectionNr   schemac                V   | j                   }t        |      }t        d|t        dt        d      t        dt        d            t        dt              t        d	t        d            t        d
d	             t        d|t        dt        d      t        dt        d      d             t        d|t        dt        d      t        dt        dd      dt        d            t        dd             t        d|t        dt              t        dt        t        d                   |S )Nr8   useridTprimary_keyr'   2   a1pwpw_idxaddressemail_addressd   Fnullableorderorder_idamount      0rG   server_defaultzamount >= 0ck_order_amountr'   extraxuiduser.id)r8   r   r   r	   r   r   r   r   r   r   r   r   r   clsr8   ms      r*   _get_db_schemazModelOne._get_db_schema;   s   F#4d366":&44$(D!	
 	4d3?F3K%@		
 	:wD91#Cy	 M0AB	
 	35':i#89		
 r,   c                   | j                   }t        |      }t        d|t        dt        d      t        dt        d      d	      t        d
t        d             t        d|t        dt        d      t        dt        d      d	      t        dt        d            t        dd             t        d|t        dt        d      t        dt        dd      dt        d            t        dt        t        d            t        dd             t        d|t        dt        d      t        dt        d            t        dt        t        d             t        d!             |S )"Nr:   r;   r<   Tr=   r'   r?   FrF   r@   rS   )rO   rC   rD   rE   streetuq_emailrQ   rH   rI   rJ   
   rL   rM   rN   user_idrU   zamount > -1rP   itemdescriptionzorder.order_idzlen(description) > 5)r8   r   r   r	   r   r   r   r   r   r   r   r   rV   s      r*   _get_model_schemazModelOne._get_model_schemah   s3   F#4d366":64c2	
 	4d3?F3K%@8VBZ(_:>	
 	:wD9A#Cy	 9gz)'<=M0AB	
 	4d3=&+.:w
3C(DE23	
 r,   )	__name__
__module____qualname____requires__r8   __annotations__classmethodrY   ra    r,   r*   r6   r6   6   s8    4LFC* *X , ,r,   r6   c                  "    e Zd Z	 	 	 	 	 	 	 ddZy)_ComparesFKsNc           
        t        |d         \
  }}}}}}}}}}t        |d   |       t        ||       t        ||       t        ||       t        ||	       t        ||
       t        ||       t        ||       t        ||       t        |d   j                  D cg c]  }|j                  j                   c}|       |e|dk(  rFt        | j                        j                  |      }|d   d   }t        |d   j                  |       y t        |d   j                  |       y t        |d   j                  |       y c c}w )N   r   servergeneratedr'   )r   r   elementscolumnr'   r   bindget_foreign_keys)selfdiffr/   source_tablesource_columnstarget_tabletarget_columnsr'   conditional_namesource_schemaonupdateondelete	initially
deferrablefk_source_schemafk_source_tablefk_source_columnsfk_target_schemafk_target_tablefk_target_columnsfk_onupdatefk_ondeletefk_deferrablefk_initiallyelemfksserver_fk_names                              r*   _assert_fk_diffz_ComparesFKs._assert_fk_diff   s/   < T!W	
 	DGUO\*~.O\*m,K"K"L)$M:&$q'*:*:;$T[[;^L'#44dii(99,G!$QDGLL.1DGLL"23Qd# <s   E)NNNNNNN)rb   rc   rd   r   rh   r,   r*   rj   rj      s     3$r,   rj   c                  h    e Zd ZU d Zed        Zi Zded<   ed        Zed        Z	d Z
d Z	 dd
Zy	)AutogenTestc              #  z   K   |D ]0  }t        |t              r| j                  |      E d {    -| 2 y 7 wr%   )
isinstancelist_flatten_diffs)rr   diffsds      r*   r   zAutogenTest._flatten_diffs   s;      	A!T"..q111		1s   *;9;c                "    t         j                  S r%   )r   dbrW   s    r*   	_get_bindzAutogenTest._get_bind   s    yyr,   zDict[Any, Any]configure_optsc                    t                | j                         | _        | j                         | _        | j                  j                  | j                         | j                         | _        y r%   )r!   r   rp   rY   m1
create_allra   m2r   s    r*   setup_classzAutogenTest.setup_class   sJ    ==?##%#((#&&(r,   c                b    | j                   j                  | j                         t                y r%   )r   drop_allrp   r    r   s    r*   teardown_classzAutogenTest.teardown_class   s    !r,   c           
     V   | j                   j                         x| _        }dd| j                  ddddt        t
        d	}| j                  r|j                  | j                         t        j                  ||      x| _
        }t        j                  || j                        | _        y )NTupgrades
downgradesop.sa.)	compare_typecompare_server_defaulttarget_metadataupgrade_tokendowngrade_tokenalembic_module_prefixsqlalchemy_module_prefixinclude_objectinclude_name
connectionopts)rp   connectconnr   r3   r4   r   updater   	configurecontextr   AutogenContextautogen_context)rr   r   ctx_optsr   s       r*   setUpzAutogenTest.setUp   s    99,,..	D &*#ww'+%*(-51

 OOD//0!1!;!;("
 	
w  #11'477Cr,   c                8    | j                   j                          y r%   )r   closerr   s    r*   tearDownzAutogenTest.tearDown   s    		r,   Nc                    ||| j                   j                  d<   ||g| j                   _        ||g| j                   _        | j                   S )Ninclude_schemas)r   r   _object_filters_name_filters)rr   object_filtersname_filtersr   s       r*   _update_contextzAutogenTest._update_context  sZ     &;JD  %%&78%4B3CD  0#2>D  .###r,   )NNN)rb   rc   rd   r   rg   r   r   rf   r   r   r   r   r   rh   r,   r*   r   r      sd       &(NN') )  D* GK	$r,   r   c                  ,    e Zd ZddeeddfdZd Zd Zy)AutogenFixtureTestFNc	                   |r0| j                   j                  }	|	j                  }
|x|	_        |	_        	 ||c| _        }t        j                  | j                        D ]  }|j                  | j                           | j                   j                         5 }dd|dddd|||d
}|r|j                  |       t        j                  ||      x| _        }t        j                  ||      }t        j                   g       }t#        j$                  ||       |r2|cd d d        |r%| j                   j                  }	
x|	_        |	_        S S |j'                         cd d d        |r%| j                   j                  }	
x|	_        |	_        S S # 1 sw Y   nxY w	 |r%| j                   j                  }	
x|	_        |	_        y y # |r%| j                   j                  }	
x|	_        |	_        w w xY w)	NTr   r   r   r   )
r   r   r   r   r   r   r   r   r   r   r   r   )rp   dialectmax_identifier_length#_user_defined_max_identifier_length_alembic_metadatar   to_listr   r   r   r   r   r   r   r   r   
UpgradeOpsr   _produce_net_changesas_diffs)rr   r   r   r   r   r   r   
return_opsr   r   existing_lengthmodel_metadatarX   r   r   r   r   uos                     r*   _fixturezAutogenFixtureTest._fixture  s    !ii''G%;;O &&G);%	$572D"N\\$"8"89 (TYY'( ""$ )$(.2'5%/'3-205&4$0'6 OOD))9)C)C#(* w #&"4"4Wn"M^^+11/2F1) )8 %))++ $$-? % ;;=5) )8 %))++ $$-? %9) ) )8 %))++ $$-? %$))++ $$-? %s1   A#G BF	G F	G FG )G*c                B    t                t        j                  | _        y r%   )r!   r   r   rp   r   s    r*   r   zAutogenFixtureTest.setUpG  s    II	r,   c                    t        | d      r?t        j                  | j                        D ]  }|j	                  | j
                          t                y )Nr   )hasattrr   r   r   r   rp   r    )rr   rX   s     r*   r   zAutogenFixtureTest.tearDownK  sA    4,-\\$"8"89 &

499%&r,   )rb   rc   rd   r3   r4   r   r   r   rh   r,   r*   r   r     s&    
 .*"6$pr,   r   )2
__future__r   typingr   r   r   
sqlalchemyr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r    r   r   r   ddl.baser   	migrationr   
operationsr   testingr   r   testing.envr    r!   setr"   rf   listens_forr+   r2   r3   r4   r6   rj   r   r   rh   r,   r*   <module>r      s    "     &   !          '      )    , &"u H $ 5/0' 1'  7  6! s !_ _D4$ 4$n<$, <$~A Ar,   