o
    pj                     @  s   d Z ddlmZ ddlZddlZddlmZ ee j	d Z
ejdee
 ejdZedur;eeds;ejd= ddlmZ ddlmZmZmZ dd	lmZ G d
d dejZedkrfejdd dS dS )z#Deterministic agent runtime checks.    )annotationsN)Path   platform__path__)AgentResolutionErrorresolve_basic_instructionresolve_instruction)manifest_toolsc                   @  s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )AgentRuntimeChecksc                 C  s   t tjdd| _d S )NF)compact)r
   abn_appAPP_MANIFESTtoolsself r   &tests/platform/agent_runtime_checks.pysetUp   s   zAgentRuntimeChecks.setUpc                 C  sd   t d| j}| d|d  | d|d  | d|d  | d|d	 d
  | d|d  d S )Nz/Check whether ABN 51 824 753 556 is registered.deterministic_v1resolverzbusiness.au.abn.lookup
capability	lookup_v1action51824753556	argumentsabnneverconfirmation)r   r   assertEqual)r   	selectionr   r   r   0test_resolves_abn_instruction_to_existing_action   s   zCAgentRuntimeChecks.test_resolves_abn_instruction_to_existing_actionc                 C  sJ   |  t}td| j W d    n1 sw   Y  | d|jj d S )Nz&Find a company called Example Pty Ltd.no_matching_tool)assertRaisesr   r   r   r   	exceptioncoder   raisedr   r   r   5test_rejects_instruction_without_supported_tool_input&   s   zHAgentRuntimeChecks.test_rejects_instruction_without_supported_tool_inputc                 C  sH   |  t}tdg  W d    n1 sw   Y  | d|jj d S )NCheck ABN 51824753556.r"   )r#   r   r   r   r$   r%   r&   r   r   r   /test_cannot_select_tool_not_available_to_tenant+   s   zBAgentRuntimeChecks.test_cannot_select_tool_not_available_to_tenantc                 C  s   G dd d}| }t d| j|d}| d|d  | d|j t d| jd	d
i|d}| d|d  | d|d  | d|j d S )Nc                   @  s    e Zd ZdZdd Zdd ZdS )zeAgentRuntimeChecks.test_optional_provider_is_used_only_after_deterministic_no_match.<locals>.Selectortest_providerc                 S  s
   d| _ d S )Nr   )callsr   r   r   r   __init__4   s   
znAgentRuntimeChecks.test_optional_provider_is_used_only_after_deterministic_no_match.<locals>.Selector.__init__c                 S  s(   |  j d7  _ |d ddd| jddS )N   r   r   F)r   include_history
fake-model)toolr   providermodel)r,   name)r   messager   contextr   r   r   select7   s   zlAgentRuntimeChecks.test_optional_provider_is_used_only_after_deterministic_no_match.<locals>.Selector.selectN)__name__
__module____qualname__r4   r-   r7   r   r   r   r   Selector1   s    r;   r)   )r2   r   r   r   z.Please check the supplied business identifier.	tenant_idztenant-a)r6   r2   r+   r0   r3   r.   )r	   r   r   r,   )r   r;   selectordeterministicselectedr   r   r   @test_optional_provider_is_used_only_after_deterministic_no_match0   s   zSAgentRuntimeChecks.test_optional_provider_is_used_only_after_deterministic_no_matchN)r8   r9   r:   r   r!   r(   r*   r@   r   r   r   r   r      s    
r   __main__)	verbosity)__doc__
__future__r   sysunittestpathlibr   __file__resolveparentsPROJECT_ROOTpathinsertstrmodulesgetloaded_platformhasattrapps.abn_lookup_appabn_lookup_appr   bridge_platform.agents.runtimer   r   r	   #bridge_platform.agents.tool_catalogr
   TestCaser   r8   mainr   r   r   r   <module>   s"    8