o
     Loj                     @   sR   d dl Z d dlZd dlmZ d dlmZ G dd dejZedkr'e	  dS dS )    N)Path)
TfidfIndexc                   @   s   e Zd Zdd Zdd ZdS )TfidfIndexTestc                 C   s:   t ddddddg}| |ddd d	 d d S )
NlaborzAOvertime compensation is one and one-half times the regular rate.idtextscamz5Phishing messages ask you to click a suspicious link.z(How is overtime compensation calculated?   r   r   )r   buildassertEqualsearch)selfindex r   ,/root/openrights-assistant/tests/test_rag.py test_search_ranks_matching_chunk	   s
    z/TfidfIndexTest.test_search_ranks_matching_chunkc                 C   sx   t dddg}t %}t|d }|| | t |ddd d d W d    d S 1 s5w   Y  d S )	NonezA public source passage.r   z
index.jsonzpublic sourcer
   r   r   )	r   r   tempfileTemporaryDirectoryr   saver   loadr   )r   r   	directorypathr   r   r   test_round_trip   s   

$"zTfidfIndexTest.test_round_tripN)__name__
__module____qualname__r   r   r   r   r   r   r      s    r   __main__)
r   unittestpathlibr   openrights.ragr   TestCaser   r   mainr   r   r   r   <module>   s    