
    j                    X    d dl mZ d dlmZ d dlmZmZ d dlmZ d
dZ	d
dZ
d
dZd
dZy	)    )annotations)connect_memory)apply_migrationsget_schema_version)REQUIRED_TABLESc                     t               } t        |        | j                  d      D ch c]  }|d   	 }}t        t              j                  |      sJ y c c}w )Nz1SELECT name FROM sqlite_master WHERE type='table'name)r   r   executesetr   issubset)connrowtabless      tests/unit/test_schema.pytest_db_schema_can_be_createdr      sR    DT%)\\2e%fgcc&kgFg((000 hs   Ac                 N    t               } t        |        t        |       dk(  sJ y )N&   )r   r   r   )r   s    r   test_schema_version_recordedr      s%    DTd#r)))    c                 0   t               } t        |        | j                  d      j                         D ci c]  }|d   |d    }}| j                  d      j                         D ci c]  }|d   |d    }}| j                  d      j                         D ch c]  }|d   	 }}|d   j	                         dk(  sJ |d   j	                         dk(  sJ |d   j	                         dk(  sJ h d	j                  |      sJ y c c}w c c}w c c}w )
NPRAGMA table_info(transactions)r	   typez"PRAGMA table_info(crypto_holdings)zPRAGMA table_info(instruments)quantityTEXTfx_rate_to_chf>   ter	benchmark
index_namefund_domicileposition_categorydistribution_policy)r   r   r
   fetchallupperr   )r   r   tx_colscrypto_colsinstrument_colss        r   0test_decimal_sensitive_columns_use_text_affinityr'      s%   DT37<<@a3b3k3k3mnCs6{CK'nGn7;||Dh7i7r7r7tu3v;F+uKu.2ll;[.\.e.e.ghss6{hOh:$$&&000#$**,666z"((*f444jss  uD  E  E  E ouhs   D	*DDc                    t               } t        |        | j                  d      j                         D ch c]  }|d   	 }}| j                  d      j                         D ch c]  }|d   	 }}| j                  d      j                         D ch c]  }|d   	 }}h dj	                  |      sJ h dj	                  |      sJ h dj	                  |      sJ | j                  d      j                         D ch c]  }|d   	 }}h d	j	                  |      sJ | j                  d
      j                         D ch c]  }|d   	 }}h dj	                  |      sJ | j                  d      j                         D ch c]  }|d   	 }}h dj	                  |      sJ y c c}w c c}w c c}w c c}w c c}w c c}w )Nz&PRAGMA table_info(instrument_mappings)r	   z,PRAGMA table_info(platform_account_mappings)z)PRAGMA table_info(broker_import_dry_runs)>   isintickercurrencyexchange
confidenceasset_classsource_namesource_labelinstrument_idmapping_statusnormalized_namesource_platformquality_flags_json>	   r+   account_typer2   r4   internal_account_idnormalized_platforminternal_platform_idsource_account_labelnormalized_account_name>   
is_currentsummary_jsonsession_statusr4   mapped_positionssource_file_typeblocked_positionsr5   candidate_cash_rowscandidate_positionssnapshot_date_statussource_filename_hashdetected_snapshot_datez-PRAGMA table_info(broker_import_review_items)>   row_hash
dry_run_idr0   review_statusreview_item_idsource_row_refr3   r4   detected_currencyr5   reviewer_confirmeddetected_asset_classaccount_mapping_statusimport_readiness_statussnapshot_date_confirmedticker_exchange_confirmedz0PRAGMA table_info(broker_import_execution_plans)>   rH   snapshot_datepayload_statusrJ   transaction_idr4   source_row_hashexecution_statustransaction_typeexecution_plan_idtarget_account_idtarget_instrument_idpayload_quality_flags_jsonplanned_write_summary_jsonr   >   	is_voided	voided_at	voided_byvoid_reasoncorrection_reasoncorrection_of_transaction_id)r   r   r
   r"   r   )r   r   instrument_mapping_colsaccount_mapping_colsdry_run_colsreview_colsexecution_colstransaction_colss           r   ;test_broker_bank_mapping_tables_exist_with_required_columnsrj   !   s"   DT6:llCk6l6u6u6wxss6{xx37<<@n3o3x3x3z{CCK{{+/<<8c+d+m+m+opCCKpLp Q  Z  Z  [r  s  s  s F  O  O  Pd  e  e  e Z  c  c  dp  q  q  q*.,,7f*g*p*p*rs33v;sKs W  `  `  al  m  m  m-1\\:l-m-v-v-xycc&kyNy m  v  v  wE  F  F  F/3||<]/^/g/g/ijFjjv  AQ  R  R  R y{p
 tyjs#   F/&F4F9F>GGN)returnNone)
__future__r   jarvis_finance.storage.databaser   !jarvis_finance.storage.migrationsr   r   jarvis_finance.storage.schemar   r   r   r'   rj    r   r   <module>rr      s'    " : R 91*	ERr   