
    ZeIi4                    j   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% ddl$m&Z&  e'            Z(d e)d!<    e
j*        ed"          d#             Z+d$ Z,e,Z-d%e)d&<   d'Z.d%e)d(<    G d) d*          Z/ G d+ d,          Z0 G d- d.          Z1 G d/ d0e1          Z2 G d1 d2e1          Z3d'S )3    )annotations)Any)Dict)Set)CHAR)CheckConstraint)Column)event)
ForeignKey)Index)inspect)Integer)MetaData)Numeric)PrimaryKeyConstraint)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                D    t                               | j                   d S N)r#   addname)tableparents     l/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/alembic/testing/suite/_autogen_fixtures.py	new_tabler,   &   s    5:&&&&&    c                $    |dk    r	|t           v S dS )Nr)   T)r#   )objr(   type_	reflected
compare_tos        r+   _default_include_objectr3   +   s    )))tr-   r   _default_object_filtersN_default_name_filtersc                  N    e Zd ZU dZdZded<   ed             Zed             ZdS )ModelOneunique_constraint_reflectionNr   schemac                   | 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r:   useridTprimary_keyr(   2   a1pwpw_idxaddressemail_addressd   Fnullableorderorder_idamount      0rI   server_defaultzamount >= 0ck_order_amountr(   extraxuiduser.id)r:   r   r   r	   r   r   r   r   r   r   r   r   r   clsr:   ms      r+   _get_db_schemazModelOne._get_db_schema<   sw   F###4d33366"::&&44$$(D!!	
 	
 	
 	4d333?F3KK%@@@		
 	
 	
 	:wD9991#Cyy	   M0ABBB	
 	
 	
 	35':i#8#89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(   rA   FrH   rB   rU   )rQ   rE   rF   rG   streetuq_emailrS   rJ   rK   rL   
   rN   rO   rP   user_idrW   zamount > -1rR   itemdescriptionzorder.order_idzlen(description) > 5)r:   r   r   r	   r   r   r   r   r   r   r   r   rX   s      r+   _get_model_schemazModelOne._get_model_schemai   s   F###4d33366"::6664c222	
 	
 	
 	4d333?F3KK%@@@8VBZZ((_:>>>	
 	
 	
 	:wD999A#Cyy	   9gz)'<'<==M0ABBB	
 	
 	
 	4d333=&++..:w
3C(D(DEE233	
 	
 	
 r-   )	__name__
__module____qualname____requires__r:   __annotations__classmethodr[   rc    r-   r+   r7   r7   7   sa         4LF* * [*X , , [, , ,r-   r7   c                  V    e Zd ZdZddiZdddddd	Zed
             Zed             ZdS )NamingConvModelr8   conv_all_constraint_namesTzix_%(column_0_label)sz%uq_%(table_name)s_%(constraint_name)sz%ck_%(table_name)s_%(constraint_name)sz;fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)szpk_%(table_name)s)ixuqckfkpkc                H   t                      }t          d|t          dt                    t	          dd          t          dd                     t          d|t          dt                    t          dt          dd	                    t          d
d                     t          d|t          dt                    t          dt                    t          dt                    t          dd                     t          d|t          dt                    t          dd                     t          d|t          dt                    t          dt          dd                    t          dt                    t          dt                    t          dd          t          dd          t          dd          	  	         t          d|t          dt                    t          dt                    t          d          t          d                     |S )Nx1qdb_x1_index_qdb_x1_primary_qrS   x2px1.qdb_x2_foreign_qq > 5db_x2_check_qx3rsdb_x3_unique_qx4db_x4_primary_qx5x4.qdb_x5_foreign_qdb_x5_primary_qdb_x5_unique_rs > 5db_x5_check_sunnamed_sqlite)	r   r   r	   r   r   r   r   r   r   )rY   rZ   s     r+   r[   zNamingConvModel._get_db_schema   s   
 JJ3  /3'' +<===	
 	
 	
 	3  3
60ABBBCCG/:::	
 	
 	
 	3  3  3  S'7888	
 	
 	
 	3   +<===		
 	
 	
 	3  3
60ABBBCC3  3   +<===S'7888G/:::
	
 
	
 
	
 	3  3   %%S!!	
 	
 	
 r-   c                   ddl m} t          | j                  }t	          d|t          dt          d          t          d d                     t	          d|t          dt                    t          d	t          d
                    t          dd                     t	          d|t          dt                    t          dt                    t          dt                    t          dd          t          d |d                               t	          d|t          dt          d          t          dd                     t	          d|t          dt          d          t          d	t          d                    t          dt                    t          dt                    t          dd          t          dd          t          d |d                    	  	         |S )Nr   )conv)naming_conventionrt   ru   Tr?   rx   ry   rz   r|   token_x2check1rS   r~   r   r   	token_x3ruserdef_x3_unique_sr   userdef_x4_idx_qx6r   	token_x6rr   token_x6check1zs < 20userdef_x6_check_s)sqlalchemy.sql.namingr   r   r   r   r	   r   r   r   r   r   )rY   r   rZ   s      r+   rc   z!NamingConvModel._get_model_schema   s   ......s'<===!VCd;;;U4=M=M	
 	
 	
 	3  3
6**++G*:;;;	
 	
 	
 	3  3  3  S{333Stt,A'B'BCCC	
 	
 	
 	3T222$c**		
 	
 	
 	3T2223
6**++3  3  S{333G%566Hdd+?&@&@AA
	
 
	
 
	
 r-   N)	rd   re   rf   rg   configure_optsr   ri   r[   rc   rj   r-   r+   rl   rl      sv        4L148N%55K!  6 6 [6p ( ( [( ( (r-   rl   c                  $    e Zd Z	 	 	 	 	 	 	 ddZdS )_ComparesFKsNc           
        t          |d                   \
  }}}}}}}}}}t          |d         |           t          ||           t          ||           t          ||           t          ||	           t          ||
           t          ||           t          ||           t          ||           t          d |d         j        D             |           |u|dk    rRt          | j                                      |          }|d         d         }t          |d         j        |           d S t          |d         j        |           d S t          |d         j        |           d S )N   r   c                &    g | ]}|j         j        S rj   )columnr(   ).0elems     r+   
<listcomp>z0_ComparesFKs._assert_fk_diff.<locals>.<listcomp>4  s    ;;;$T[;;;r-   servergeneratedr(   )r   r    elementsr   bindget_foreign_keysr(   )selfdiffr0   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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'*:;;;^LLL'#444di((99,GG!$QDGL.11111DGL"233333Qd#####r-   )NNNNNNN)rd   re   rf   r   rj   r-   r+   r   r   	  s?         3$ 3$ 3$ 3$ 3$ 3$r-   r   c                  |    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d	S )AutogenTestc              #  ~   K   |D ]7}t          |t                    r|                     |          E d {V  3|V  8d S r&   )
isinstancelist_flatten_diffs)r   diffsds      r+   r   zAutogenTest._flatten_diffsA  se       	 	A!T"" ..q1111111111		 	r-   c                    t           j        S r&   )r   dbrY   s    r+   	_get_bindzAutogenTest._get_bindH  s
    yr-   zDict[Any, Any]r   c                    t                       |                                 | _        |                                 | _        | j                            | j                   |                                 | _        d S r&   )r"   r   r   r[   m1
create_allrc   m2r   s    r+   setup_classzAutogenTest.setup_classN  s\    ==??##%%#(###&&((r-   c                `    | j                             | j                   t                       d S r&   )r   drop_allr   r!   r   s    r+   teardown_classzAutogenTest.teardown_classV  s*    !!!r-   c           
     6   | j                                         x| _        }dd| j        ddddt          t
          d	}| j        r|                    | j                   t          j	        ||          x| _
        }t          j        || j                  | _        d S )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)r   connectconnr   r4   r5   r   updater   	configurecontextr   AutogenContextautogen_context)r   r   ctx_optsr   s       r+   setUpzAutogenTest.setUp[  s    9,,...	D &*#w'+%*(-51

 

  	1OOD/000!1!;("
 "
 "
 	
w  #1'47CCr-   c                8    | j                                          d S r&   )r   closer   s    r+   tearDownzAutogenTest.tearDownp  s    	r-   Nc                n    ||| j         j        d<   ||g| j         _        ||g| j         _        | j         S )Ninclude_schemas)r   r   _object_filters_name_filters)r   object_filtersname_filtersr   s       r+   _update_contextzAutogenTest._update_contexts  sK     &;JD %&78%4B3CD 0#2>D .##r-   )NNN)rd   re   rf   r   ri   r   r   rh   r   r   r   r   r   rj   r-   r+   r   r   @  s              [ &(N'''') ) [)   [D D D*   GK	$ 	$ 	$ 	$ 	$ 	$r-   r   c                  .    e Zd ZddeeddfdZd Zd ZdS )AutogenFixtureTestFNc	                l   |r!| j         j        }	|	j        }
|x|	_        |	_        	 ||c| _        }t          j        | j                  D ]}|                    | j                    | j                                         5 }dd|dddd|||d
}|r|	                    |           t          j        ||          x| _        }t          j        ||          }t          j        g           }t#          j        ||           |r+|cd d d            |r| j         j        }	|
x|	_        |	_        S S |                                cd d d            |r| j         j        }	|
x|	_        |	_        S S # 1 swxY w Y   	 |r| j         j        }	|
x|	_        |	_        d S d S # |r| j         j        }	|
x|	_        |	_        w xY w)	NTr   r   r   r   )
r   r   r   r   r   r   r   r   r   r   r   r   )r   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)r   r   r   r   r   r   r   
return_opsr   r   existing_lengthmodel_metadatarZ   r   r   r   r   uos                     r+   _fixturezAutogenFixtureTest._fixture  s    ! 	&i'G%;O &&G);%	$572D"N\$"899 ( (TY''''""$$ )$(.2'5%/'3-205&4$0'6   *OOD))))9)C#(* * * w #&"4Wn"M"M^+++1/2FFF )1) ) ) ) ) ) )8 % $)+ $$-??$ ;;==5) ) ) ) ) ) )8 % $)+ $$-??$9) ) ) ) ) ) ) ) )8 % $)+ $$-???$ $$ $)+ $$-?$ $ $ $s=   AF >BE)F ,E)?F )E--F 0E-1F F3c                D    t                       t          j        | _        d S r&   )r"   r   r   r   r   s    r+   r   zAutogenFixtureTest.setUp  s    I			r-   c                    t          | d          r6t          j        | j                  D ]}|                    | j                   t                       d S )Nr   )hasattrr   r   r   r   r   r!   )r   rZ   s     r+   r   zAutogenFixtureTest.tearDown  sZ    4,-- 	&\$"899 & &

49%%%%r-   )rd   re   rf   r4   r5   r  r   r   rj   r-   r+   r   r     s[        
 .*"6$ 6$ 6$ 6$p      r-   r   )4
__future__r   typingr   r   r   
sqlalchemyr   r   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#   rh   listens_forr,   r3   r4   r5   r7   rl   r   r   r   rj   r-   r+   <module>r     s   " " " " " " "                         & & & & & &             ! ! ! ! ! !                               + + + + + +                         ' ' ' ' ' '                               ) ) ) ) ) )                   , , , , , , & & & & & &"suu  $ $ $ $ 5/00' ' 10'    7  6 6 6 6!  ! ! ! !_ _ _ _ _ _ _ _Dm m m m m m m m`4$ 4$ 4$ 4$ 4$ 4$ 4$ 4$n<$ <$ <$ <$ <$, <$ <$ <$~A A A A A A A A A Ar-   