U
    h                     @  s   d 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	jZe	jZejZdd	d
dZG dd dejZedkre  dS )zUnittest for llmfn_outputs.    )annotations)Sequence)absltest)llmfn_output_row)llmfn_outputs)modelzmodel_lib.ModelResults)returnc                   C  s   t jdg dS )N )model_inputtext_results)	model_libZModelResults r   r   W/tmp/pip-unpacked-wheel-doshhd5e/google/generativeai/notebook/lib/llmfn_outputs_test.py_get_empty_model_results   s    r   c                   @  s2   e Zd ZddddZdd Zdd Zd	d
 ZdS )LLMFnOutputsTestzSequence[LLMFnOutputEntry])outputsc                 C  sf   d}|D ]}|d }q|  || | |d t |  |d d |d  | |d d d t d S )Nr      )Z	assertLenZassertIsInstanceLLMFnOutputEntry)selfr   count_r   r   r   _test_is_sequence$   s    
z"LLMFnOutputsTest._test_is_sequencec              
   C  sZ   g }t ddD ]4}dddg| }t|d|i |t g d}|| qt|}| | d S )Nr      onetwothree
prompt_numZ	input_numpromptZprompt_varsr
   Zmodel_resultsZoutput_rows)ranger   r   appendLLMFnOutputsr   )r   Ztmp_entry_listr   r   output_entryr   r   r   r   test_is_sequence4   s    	z!LLMFnOutputsTest.test_is_sequencec                 C  s  g }t ddD ]n}dddg| }dddg| }t|d|i |t tdd	|d
tdtdd|d
tdgd}|| qddddddgddddddgddddddgddddddgddddddgd}t|}| ||	  | t
| t
|	   d S )Nr   r   r   r   r   redgreenblue{}_one)
Result Numr   dataZresult_typer   {}_twor      red_onered_two	green_one	green_twoblue_oneblue_two)
Prompt Num	Input Numr)   Promptr   r    r   r   LLMFnOutputRowformatstrr!   r"   assertEqualZas_dictlistkeysr   Zoutputs_listr   r   r   r#   expected_dictr   r   r   r   test_as_dict_basicF   sR    z#LLMFnOutputsTest.test_as_dict_basicc                 C  s<  g }t ddD ]z}dddg| }dddg| }t|d|i |t td	d|d
dd|itdtd	d|d
dd|itdgd}|| qddddddgddddddgddddddgddddddgd
d
d d d d gd d d
d
d d gd d d d d
d
gddddddgd}t|}| ||	  | t
| t
|	   d S )Nr   r   r   r   r   r%   r&   r'   r)   Tr   r(   r*   r   r,   r   r-   r.   r/   r0   r1   r2   r3   )r4   r5   r)   r6   r%   r&   r'   r   r7   r>   r   r   r   test_as_dict_with_holesy   sh          z(LLMFnOutputsTest.test_as_dict_with_holesN)__name__
__module____qualname__r   r$   r@   rA   r   r   r   r   r   "   s   3r   __main__N)__doc__
__future__r   typingr   Zabsl.testingr   Z google.generativeai.notebook.libr   r   r   r   r   r"   r8   r   ZTestCaser   rB   mainr   r   r   r   <module>   s    