
    pj(                       d dl mZ d dlZd dlmc mZ d dlZd dl	m
Z
 d dlZd dlmZmZmZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZ d ZddZd dZd!dZ d"dZ!d"dZ"d"dZ#d"dZ$d"dZ%d"dZ&d"dZ'd!dZ(d!dZ)d"dZ*d"dZ+dS )#    )annotationsN)Path)	CandidateInputconfirm_candidatedeterministic_parse_docx#import_confirmed_candidate_snapshotqwen_extract_candidatesqwen_resolve_staged_candidatesresolve_candidatestage_docx_candidatesupsert_candidate)CatalogEntryInputupsert_catalog_entry)connect_memory)apply_migrationsc                     t                      } t          |            |                     d           |                     d           | S )NzINSERT INTO platforms(platform_id,name,platform_type,default_currency,created_at) VALUES('p1','PostFinance','broker','CHF','now')zINSERT INTO accounts(account_id,platform_id,account_name,account_type,currency,created_at) VALUES('a1','p1','Depot','brokerage','CHF','now'))r   r   execute)conns    f/home/agent/.hermes/worktrees/FinanceManager-sprint20d/tests/unit/test_instrument_import_candidates.py
setup_connr      s^    DTLL  U  V  V  VLL  `  a  a  aK    pathr   lines	list[str]returnc                    d                     d |D                       }d| d}t          j        | d          5 }|                    d|           d d d            n# 1 swxY w Y   | S )N c              3  "   K   | ]
}d | dV  dS )z<w:p><w:r><w:t>z</w:t></w:r></w:p>N ).0lines     r   	<genexpr>zmake_docx.<locals>.<genexpr>!   s.      PP$=T===PPPPPPr   z<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body>z</w:body></w:document>wzword/document.xml)joinzipfileZipFilewritestr)r   r   bodyxmlzfs        r   	make_docxr+       s    77PP%PPPPPD{\`{ { {C	s	#	# .r
'---. . . . . . . . . . . . . . .Ks   AA"%A"r   c                 ~    t          ddddddddd	dddd	d
          }|                    |            t          di |S )Nbroker.docxpostfinance1
Sample ETFSAMPr   CHF1.2345etfneeds_manual_review)source_fileplatformsource_row_numberraw_name
raw_tickerraw_isinraw_currencyraw_quantityraw_asset_classproposed_nameproposed_tickerproposed_currencyproposed_asset_classmapping_statusr   )dictupdater   )	overridesdatas     r   	candidaterH   )   sh    !"",  D  	KK	!!D!!!r   tmp_pathNonec                   t          | dz  dg          }t          |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         }|j        }d}||k    }|st          j        d|fd||f          t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}x}}|d         }|j        }d}||k    }|st          j        d|fd||f          t          j        |          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}x}}d S )NzPostfinance.docx"Sample ETF CH0000000001 CHF 12.345r.   r7      ==z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)slenrowspy0py1py3py6assert %(py8)spy8r   CH0000000001)z0%(py3)s
{%(py3)s = %(py1)s.raw_isin
} == %(py6)srV   rW   rX   exact_isin_match)z6%(py3)s
{%(py3)s = %(py1)s.mapping_status
} == %(py6)s)r+   r   rR   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr;   rC   )	rI   docxrS   @py_assert2@py_assert5@py_assert4@py_format7@py_format9@py_assert0s	            r   ,test_deterministic_parser_creates_candidatesrm   >   s   X 225Y4Z[[D#D=AAADt999>933tt97-7-~-~----------~-----7--------~-----------------------------777!7%77!%77777777777!%77777777777!7777%77777777777777777777777777777777r   c                $	   i  G d d          fd}|                      d|           t                      }t          dgdd          \  }}d	}||u }|st          j        d
|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          dz  }dd|iz  }t          t          j
        |                    d x}}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         }||v}|slt          j        d|fd||f          t          j        |          t          j        |          dz  }dd|iz  }t          t          j
        |                    d x}x}}|d         }|j        }d }	||	k    }
|
st          j        d|
fd!||	f          t          j        |          t          j        |          t          j        |	          d"z  }dd|iz  }t          t          j
        |                    d x}x}x}
}	t          ||d                    |                    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$         }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 )'Nc                       e Zd Zd Zd Zd ZdS )Ntest_qwen_extraction_creates_only_candidates_no_bookings.<locals>.FakeResponsec                    | S Nr   selfs    r   	__enter__zXtest_qwen_extraction_creates_only_candidates_no_bookings.<locals>.FakeResponse.__enter__I       D[r   c                    dS NFr   rt   argss     r   __exit__zWtest_qwen_extraction_creates_only_candidates_no_bookings.<locals>.FakeResponse.__exit__J       %%r   c                    dS )Ns   {"choices":[{"message":{"content":"{\"positions\":[{\"name\":\"Q ETF\",\"ticker\":\"QETF\",\"currency\":\"CHF\",\"quantity\":\"1.23\",\"asset_class\":\"etf\",\"row_number\":2,\"confidence\":\"medium\"}]}"}}]}r   rs   s    r   readzStest_qwen_extraction_creates_only_candidates_no_bookings.<locals>.FakeResponse.readK   s     _  _r   N__name__
__module____qualname__ru   r{   r~   r   r   r   FakeResponserp   H   s:        (((///	_ 	_ 	_ 	_ 	_r   r   c                R    | j                             d          d<                S Nzutf-8r(   rG   decodereqkwargsr   captureds     r   fake_urlopenzNtest_qwen_extraction_creates_only_candidates_no_bookings.<locals>.fake_urlopenM   '    8??733|~~r   <jarvis_finance.imports.instrument_candidates.request.urlopenzQ ETF CHF 1.23z	True.docxtrue_wealth)r6   r7   Tis)z%(py0)s is %(py3)s	available)rU   rW   zassert %(py5)spy5rN   rO   rQ   rR   rS   rT   rY   rZ   z1.23r(   not inz%(py1)s not in %(py4)srV   py4assert %(py6)srX   r   r   )z4%(py3)s
{%(py3)s = %(py1)s.raw_quantity
} == %(py6)sr\   6SELECT COUNT(*) AS c FROM instrument_import_candidatescz%(py1)s == %(py4)s&SELECT COUNT(*) AS c FROM transactions)setattrr   r	   r^   r_   r`   ra   rb   rc   rd   re   rR   r=   r   r   fetchone)monkeypatchr   r   rS   r   rg   @py_assert1@py_format4@py_format6rh   ri   rj   rk   rl   @py_assert3@py_format5r   r   s                   @@r   8test_qwen_extraction_creates_only_candidates_no_bookingsr   F   s   H_ _ _ _ _ _ _ _
      VXdeee<<D-/?.@kdqrrrOD)9999t999>933tt9)&))6)))))))))))6))))))6))))))))))))))))))))))))))))))))7%7%2%2%%%%%%%%%%2%%%%%7%%%%%%%%2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%T47###<<PQQZZ\\]`afeffaefffffffffffaeffffffaffffeffffffffffffffffffffffffffff<<@AAJJLLSQVUVVQUVVVVVVVVVVVQUVVVVVVQVVVVUVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVr   c                    t                      } t          | t          ddd                    }t          | |          }|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 )
Nr   r;   proposed_isinproposed_exchangerC   r5   rO   r   r   r   rX   )	r   r   rH   r   r^   r_   rc   rd   re   r   cidresultrl   r   rg   r   rj   s           r   5test_candidate_without_isin_stays_needs_manual_reviewr   \   s    <<D
4Bb\^!_!_!_
`
`CtS))F"#<'<<#'<<<<<<<<<<<#'<<<<<<#<<<<'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<r   c                    t                      } t          | t          ddddddd          d	           t          | t	          dd
                    }t          | |          }|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 )Nr4   r0   r[   r1   SWXr2   )asset_classnameisintickerexchangetrading_currencyinstrument_currencytest)noter;   r   rC   r]   rO   r   r   r   rX   )r   r   r   r   rH   r   r^   r_   rc   rd   re   r   s           r   0test_candidate_with_isin_can_be_exact_isin_matchr   c   sC   <<D0U\jsy  EJ  ]b  x}   ~   ~   ~  EK  L  L  L  L
4NR`!a!a!a
b
bCtS))F"#9'99#'99999999999#'999999#9999'999999999999999999999999999999r   c            	     z   t                      } t          | t          dddd                    }t          j        t
                    5  t          | |dd           d d d            n# 1 swxY w Y   t          j        t
                    5  t          | |dddd	
           d d d            d S # 1 swxY w Y   d S )Nr   r1   )r;   r   r   r@   manual review confirms)r   r@   a1
2025-12-31noT
account_idsnapshot_dater   confirm)r   r   rH   pytestraises
ValueErrorr   r   )r   r   s     r   ,test_ticker_alone_does_not_confirm_or_importr   k   sb   <<D
4Bb\^pv!w!w!w
x
xC	z	"	" \ \$*BTZ[[[[\ \ \ \ \ \ \ \ \ \ \ \ \ \ \	z	"	" } }+D#$Vbimw{||||} } } } } } } } } } } } } } } } } }s$   	A))A-0A-B00B47B4c                 0   t                      } t          | t                                }t          | |dddd           |                     d|f                                          }|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         }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 )Nr   r1   r   r2   )r   r@   r   rA   zLSELECT mapping_status FROM instrument_import_candidates WHERE candidate_id=?rC   	confirmedrO   r   r   r   rX   zDSELECT COUNT(*) AS c FROM audit_log WHERE action='confirm_candidate'r   rN   )r   r   rH   r   r   r   r^   r_   rc   rd   re   )r   r   rowrl   r   rg   r   rj   s           r   'test_manual_confirmation_sets_confirmedr   t   s   <<D
4
-
-CdC&>PVjo  DI  J  J  J  J
,,ehkgm
n
n
w
w
y
yC /K/ K////////// K///// ////K///////////////////////////<<^__hhjjknotsttostttttttttttosttttttottttsttttttttttttttttttttttttttttttr   c            	        t                      } t          | t          dd                    }t          | |ddddd           t	          | |dd	d
d          }|                     d|f                                          }|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         }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         }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         }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 )Nr[   r   r   r1   r   r2   )r   r   r@   r   rA   r   r   zapproved importTr   zWSELECT transaction_type, source_type, quantity FROM transactions WHERE transaction_id=?transaction_typeinitial_position_snapshotrO   r   r   r   rX   source_typebroker_import_reviewed_snapshotquantityr3   zESELECT COUNT(*) AS c FROM alerts WHERE rule_id='cost_basis_uncertain'r   rN   zVSELECT COUNT(*) AS c FROM audit_log WHERE action='import_confirmed_candidate_snapshot')r   r   rH   r   r   r   r   r^   r_   rc   rd   re   )	r   r   tx_idr   rl   r   rg   r   rj   s	            r   Ntest_confirmed_candidate_can_create_initial_snapshot_with_uncertain_cost_basisr   }   s   <<D
4NR`!a!a!a
b
bCdC&>nnt  IN  bg  h  h  h  h/cdZfm~  IM  N  N  NE
,,psxrz
{
{  E  E  G  GC!"A&AA"&AAAAAAAAAAA"&AAAAAA"AAAA&AAAAAAAAAAAAAAAAAAAAAAAAAAAA}B!BB!BBBBBBBBBBB!BBBBBBBBBB!BBBBBBBBBBBBBBBBBBBBBBBBBBBBz?&h&?h&&&&&&&&&&?h&&&&&?&&&&h&&&&&&&&&&&&&&&&&&&&&&&&&&&<<_``iikkloputuuptuuuuuuuuuuuptuuuuuupuuuutuuuuuuuuuuuuuuuuuuuuuuuuuuuu<<pqqzz||  ~A  B  G  FG  G  B  FG  G  G  G  G  G  G  G  G  G  G  B  FG  G  G  G  G  G  B  G  G  G  G  FG  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  G  Gr   c            	     8   t                      } t          | t                                }t          j        t
                    5  t          | |dddd           d d d            n# 1 swxY w Y   |                     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 S )Nr   r   blockedTr   r   r   r   rO   r   r   r   rX   )r   r   rH   r   r   r   r   r   r   r^   r_   rc   rd   re   )r   r   rl   r   rg   r   rj   s          r   5test_unconfirmed_candidate_cannot_productively_importr      s   <<D
4
-
-C	z	"	" B B+D#$Vbir  }A  	B  	B  	B  	BB B B B B B B B B B B B B B B<<@AAJJLLSQVUVVQUVVVVVVVVVVVQUVVVVVVQVVVVUVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVs   A&&A*-A*c                D   t                      }t          | dz  dg          }t          ||gd          }|j        }d}||k    }|st	          j        d|fd||f          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 S )NzTrue_Wealth.docxrL   T)dry_runrN   rO   )z8%(py2)s
{%(py2)s = %(py0)s.candidates_total
} == %(py5)sr   rU   py2r   assert %(py7)spy7r   r   r   r   r   r   rX   )r   r+   r   candidates_totalr^   r_   r`   ra   rb   rc   rd   re   r   r   )rI   r   rf   r   r   ri   r   r   @py_format8rl   rg   r   rj   s                r   1test_stage_docx_candidates_dry_run_writes_no_rowsr      s   <<DX 225Y4Z[[D"4$>>>F"'a'"a''''''''''"a''''''''''''6'''''6''''''"''''a'''''''''''''''''''''''''''<<PQQZZ\\]`afeffaefffffffffffaeffffffaffffeffffffffffffffffffffffffffffffr   c                B   | dz  dz  }|j                                          t          |dg           d}t          ||          }|sd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  }t          t          j
        |                    d x}}d S )
Nrepor-   z Synthetic ETF CH0000000001 CHF 1r   rM   z>assert %(py5)s
{%(py5)s = %(py0)s(%(py1)s, platform=%(py3)s)
}r   	repo_docx)rU   rV   rW   r   )parentmkdirr+   r   r`   ra   r^   rb   rc   rd   re   )rI   r   rg   ri   r   s        r   0test_no_real_data_in_repo_git_safety_placeholderr      s(   6!M1Ii<=>>>8>?#I????????????????#?????#?????????????I?????I????????????????????????????????r   c                	   t                      }t          |t          dd                    i  G fdd          fd}|                     d|           t	          |d	          }|j        }d
}||u }|st          j        d|fd||f          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}}|j        }d
}||u }|st          j        d|fd||f          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}}|j        }d}||k    }|st          j        d|fd||f          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         }|	|v}
|
slt          j        d|
fd|	|f          t          j        |	          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}	x}
}d}	d         }|	|v}
|
slt          j        d|
fd|	|f          t          j        |	          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}	x}
}|                    df                                          }|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!         }|	|v }
|
slt          j        d"|
fd#|	|f          t          j        |	          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}	x}
}d S )$Nz999.123r   )r=   r   c                  &    e Zd Zd Zd Z fdZdS )Htest_qwen_resolver_sends_sanitized_candidates_only.<locals>.FakeResponsec                    | S rr   r   rs   s    r   ru   zRtest_qwen_resolver_sends_sanitized_candidates_only.<locals>.FakeResponse.__enter__   rv   r   c                    dS rx   r   ry   s     r   r{   zQtest_qwen_resolver_sends_sanitized_candidates_only.<locals>.FakeResponse.__exit__   r|   r   c                r    dz  }dd l }|                    ddd|iigi                                          S )Na  {"updates":[{"candidate_id":"%s","proposed_name":"Sample ETF","proposed_ticker":"SAMP","proposed_isin":"","proposed_exchange":"","proposed_currency":"CHF","proposed_asset_class":"etf","mapping_status":"needs_manual_review","review_note":"Ticker-only candidate remains manual review."}]}r   choicesmessagecontentjsondumpsencode)rt   r(   r   r   s      r   r~   zMtest_qwen_resolver_sends_sanitized_candidates_only.<locals>.FakeResponse.read   sQ     t  wz  zDKKK::yI	47H+I*JKLLSSUUUr   Nr   r   s   r   r   r      G        (((///	V 	V 	V 	V 	V 	V 	Vr   r   c                R    | j                             d          d<                S r   r   r   s     r   r   zHtest_qwen_resolver_sends_sanitized_candidates_only.<locals>.fake_urlopen   r   r   r   zqwen-3.6-agent)modelTr   )z6%(py2)s
{%(py2)s = %(py0)s.qwen_available
} is %(py5)sr   r   r   r   )z1%(py2)s
{%(py2)s = %(py0)s.qwen_used
} is %(py5)sr   rO   )z7%(py2)s
{%(py2)s = %(py0)s.confirmed_after
} == %(py5)sr(   r   r   r   r   rX   r=   zYSELECT mapping_status, review_note FROM instrument_import_candidates WHERE candidate_id=?rC   r5   r   zmanual reviewreview_note)in)z%(py1)s in %(py4)s)r   r   rH   r   r
   qwen_availabler^   r_   r`   ra   rb   rc   rd   re   	qwen_usedconfirmed_afterr   r   )r   r   r   r   r   ri   r   r   r   rl   rg   r   rj   r   r   r   r   s                 @@@r   2test_qwen_resolver_sends_sanitized_candidates_onlyr      s9   <<D
4	UW!X!X!X
Y
YCHV V V V V V V V V V      VXdeee+D8HIIIF (D( D(((((((((( D((((((((((((6(((((6(((((( ((((D(((((((((((((((((((((((((((#t#t##########t############6#####6##########t###########################!&Q&!Q&&&&&&&&&&!Q&&&&&&&&&&&&6&&&&&6&&&&&&!&&&&Q&&&&&&&&&&&&&&&&&&&&&&&&&&&,HV,,9,,,,,,,,,,,9,,,,,,9,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1&!11>!11111111111>!111111>1111!1111111111111111111111111111
,,ruxtz
{
{  E  E  G  GC 9$99 $99999999999 $999999 9999$99999999999999999999999999990c-00?00000000000?000000?0000000000000000000000000000000000r   c                   t                      }t          |t          ddd                     G fdd          |                     dfd           t	          |          }|j        }d}||k    }|st          j        d|fd	||f          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f                                          }|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 )Nr   r   c                  &    e Zd Zd Zd Z fdZdS )Ftest_qwen_resolver_does_not_accept_invented_isin.<locals>.FakeResponsec                    | S rr   r   rs   s    r   ru   zPtest_qwen_resolver_does_not_accept_invented_isin.<locals>.FakeResponse.__enter__   rv   r   c                    dS rx   r   ry   s     r   r{   zOtest_qwen_resolver_does_not_accept_invented_isin.<locals>.FakeResponse.__exit__   r|   r   c                r    dd l }dz  }|                    ddd|iigi                                          S )Nr   a  {"updates":[{"candidate_id":"%s","proposed_name":"Sample ETF","proposed_ticker":"SAMP","proposed_isin":"CH9999999999","proposed_exchange":"SWX","proposed_currency":"CHF","proposed_asset_class":"etf","mapping_status":"probable","review_note":"Qwen guessed an ISIN."}]}r   r   r   r   )rt   r   r(   r   s      r   r~   zKtest_qwen_resolver_does_not_accept_invented_isin.<locals>.FakeResponse.read   sQ    KKK a  dg  gD::yI	47H+I*JKLLSSUUUr   Nr   r   s   r   r   r      r   r   r   r   c                                  S rr   r   )akr   s     r   <lambda>zBtest_qwen_resolver_does_not_accept_invented_isin.<locals>.<lambda>   s    hththvhv r   rN   rO   )z0%(py2)s
{%(py2)s = %(py0)s.warnings
} == %(py5)sr   r   r   r   z[SELECT proposed_isin, mapping_status FROM instrument_import_candidates WHERE candidate_id=?r   r   r   r   rX   rC   probable)r   r   rH   r   r
   warningsr^   r_   r`   ra   rb   rc   rd   re   r   r   )r   r   r   r   ri   r   r   r   r   rl   rg   r   rj   r   r   s                @@r   0test_qwen_resolver_does_not_accept_invented_isinr
     s   <<D
4Bb\^!_!_!_
`
`CV V V V V V V V V V VXvXvXvXvwww+D11F?a?a?a66?a
,,twzv|
}
}  G  G  I  IC%2%2%%%%%%%%%%2%%%%%%%%%2%%%%%%%%%%%%%%%%%%%%%%%%%%% .J. J.......... J..... ....J.............................r   )r   r   r   r   r   r   )r   r   )rI   r   r   rJ   )r   rJ   ),
__future__r   builtinsr`   _pytest.assertion.rewrite	assertionrewriter^   r%   pathlibr   r   ,jarvis_finance.imports.instrument_candidatesr   r   r   r   r	   r
   r   r   r   "jarvis_finance.market_data.catalogr   r   jarvis_finance.storage.databaser   !jarvis_finance.storage.migrationsr   r   r+   rH   rm   r   r   r   r   r   r   r   r   r   r   r
  r   r   r   <module>r     sO   " " " " " "                     
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 W V V V V V V V : : : : : : > > > > > >     " " " "*8 8 8 8W W W W,= = = =: : : :} } } }u u u u
G 
G 
G 
GW W W Wg g g g@ @ @ @1 1 1 1:/ / / / / /r   