
    Lrdj                    l    d dl mZ d dlZd dlmc mZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ dd	Zdd
ZdS )    )annotationsN)create_alert)check_missing_fx)connect_memory)apply_migrationsreturnNonec                    t                      } t          |            t          | ddd          }|                     d|f                                          }t          |          }dd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 S )Nwichtigdata_qualityzDemo warning)prioritycategorymessagez6SELECT priority, category FROM alerts WHERE alert_id=?)r   r   ==z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sdictrowpy0py1py3py6assert %(py8)spy8)r   r   r   executefetchoner   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation)connalert_idr   @py_assert2@py_assert5@py_assert4@py_format7@py_format9s           l/home/agent/.hermes/worktrees/FinanceManager-sprint7-postfinance-portfolio-source/tests/unit/test_quality.pytest_create_alertr.   	   s   DTD9~WefffH
,,ORZQ\
]
]
f
f
h
hC99KYNKKK9KKKKKKKKKKK9KKKKKKKKKKKKK4KKKKK4KKKKKKKKKKKKKKKKKKKKKKKK9KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK    c                 >   t                      } t          |            |                     d           |                     d           |                     d           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}||k    }|slt	          j        d|fd||f          t	          j	        |          t	          j	        |          dz  }	dd|	iz  }t          t	          j        |                    d x}x}}d S )NzcINSERT INTO platforms(platform_id,name,platform_type,created_at) VALUES('p1','Demo','broker','now')z|INSERT INTO accounts(account_id,platform_id,account_name,account_type,created_at) VALUES('a1','p1','Demo','brokerage','now')z
        INSERT INTO transactions(transaction_id,transaction_type,account_id,trade_date,currency_original,fx_status,source_type,created_at)
        VALUES('t1','buy','a1','2026-01-01','USD','missing','manual','now')
       r   r   r   r&   r   r   r   z.SELECT priority, category, rule_id FROM alertsr   kritisch)z%(py1)s == %(py4)s)r   py4zassert %(py6)sr   r   fx)r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   )
r&   r(   r)   r*   r+   r,   r   @py_assert0@py_assert3@py_format5s
             r-   &test_missing_fx_creates_critical_alertr8      s   DTLLvwwwLL  P  Q  Q  QLL  	 	 	 D!!&Q&!Q&&&&&&&&&&!Q&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&D&&&&&D&&&&&&!&&&&Q&&&&&&&&&&&&&&&&&&&&&&&&&&&
,,G
H
H
Q
Q
S
SCz?(j(?j((((((((((?j(((((?((((j(((((((((((((((((((((((((((z?"d"?d""""""""""?d"""""?""""d"""""""""""""""""""""""""""""r/   )r   r	   )
__future__r   builtinsr    _pytest.assertion.rewrite	assertionrewriter   jarvis_finance.quality.alertsr   jarvis_finance.quality.checksr   jarvis_finance.storage.databaser   !jarvis_finance.storage.migrationsr   r.   r8    r/   r-   <module>rC      s    " " " " " "               6 6 6 6 6 6 : : : : : : : : : : : : > > > > > >L L L L# # # # # #r/   