
    ni	              	          d dl Zd dlmc mZ d dlZd dlZd dlZd dl	m
Z
 d dlmZ  e             ej                            ej                            ej                            ej                            e                                         d dlmZ ej        d             Zej        d             Zej        d             Zej        d             Z ej        d	
          d             ZdS )    N)	MagicMock)load_dotenv)BaseLLMc                     |                      dd           |                      dd           |                      dd           |                      dd           d	S )
zSet fake env vars for testing.GEMINI_API_KEYfake_keySLACK_BOT_TOKENz	xoxb-fakeSLACK_SIGNING_SECRETfake_secretDATA_DIRz/tmp/butler_test_dataN)setenv)monkeypatchs    '/root/projects/butler/tests/conftest.pymock_envr      sf     '444(+666-}===z#:;;;;;    c                      dd} | S )z>Factory to create a mock LLM that returns specific text/tools.HelloNc                 L    t          t                    }| |f|j        _        |S )N)spec)r   r   generate_responsereturn_value)response_text
tool_callsllms      r   _createz"mock_llm_response.<locals>._create   s'    W%%%.;Z-H*
r   )r   N r   s    r   mock_llm_responser      s       
 Nr   c              #   6  K   ddl m} ddl}d|                                 } ||          }|j                                        r|j                                         |V  |j                                        r|j                                         dS dS )z%Provide a clean context storage path.r   )ContextStorageNtest_channel_)slack_bot.context.storager    uuiduuid4	file_pathexistsunlink)tmp_pathr    r#   
channel_idstorages        r   clean_context_storager+   !   s       988888 KKK///JnZ((G!! #  """
MMM!! #  """""# #r   c                      dd} | S )z'Factory to create CLI bots for testing.FNc                 b    ddl m} dd l}||                    d          } || ||          S )Nr   )CLIBotbutler_test_)prefix)use_real_llm
session_idtest_data_dir)tools.cli_botr.   tempfilemkdtemp)r1   r2   r3   r.   r5   s        r   r   z cli_bot_factory.<locals>._create6   s]    ((((((  $,,N,CCMv%!'
 
 
 	
r   )FNNr   r   s    r   cli_bot_factoryr7   3   s    
 
 
 
 Nr   function)scopec                 ~    |dz  }|                                  |                     dt          |                     |S )z7Automatically isolate test data for each test function.butler_testr   )mkdirr   str)r   r(   test_dirs      r   isolated_test_datar?   E   s?     -'HNNz3x==111Or   )builtins@py_builtins_pytest.assertion.rewrite	assertionrewrite
@pytest_arpytestossysunittest.mockr   dotenvr   pathappenddirnameabspath__file__slack_bot.llm.baser   fixturer   r   r+   r7   r?   r   r   r   <module>rR      sd                 				 



 # # # # # #        0I0I J JKK L L L & & & & & &< < <    # # #"   " j!!!  "!  r   