o
    pj                     @  s   d Z ddlmZ ddlZddlZddlmZ ddlmZ ee	
 jd Zejdee ejdZedurAeedsAejd= ddlmZ dd	lmZ d
ddidi dZG dd dejZedkrkejdd dS dS )z3Standalone ABN Lookup Standard v1 migration checks.    )annotationsN)Path)patch   platform__path__)manifest_toolsz	request-1	tenant_idztenant-aabn_lookup_app)
request_idtenantapp_idpayloadc                   @  s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )AbnAppContractChecksc                 C  sx   t tjdd}| dt| | d|d d  | d|d d d	  | d
|d d  | dg|d d  d S )NF)compact   business.au.abn.lookupr   
capabilityreadriskcategoryneverconfirmationzabn_lookup.readrequired_permissions)r   appAPP_MANIFESTassertEquallen)selftools r    )tests/platform/abn_app_contract_checks.pyAtest_lookup_is_agent_ready_without_exposing_health_or_credentials   s   zVAbnAppContractChecks.test_lookup_is_agent_ready_without_exposing_health_or_credentialsc                 C  s*   |  g tj  |  dtjd d S )N	lookup_v1r   )r   r   r   validateaction_for_capability)r   r    r    r!   )test_manifest_is_valid_and_exports_lookup%   s
   
z>AbnAppContractChecks.test_manifest_is_valid_and_exports_lookupc              	   C  s   t jtdd d$ t td}ttd}W d    n1 s w   Y  W d    n1 s/w   Y  | d|d  | |d d  |  d S )	N_guidreturn_valuelookup_abn_v1	health_v1okstatusdatacredential_configured)r   objectr   handle_requestCONTEXTr   assertFalseassert_not_called)r   lookupr   r    r    r!   %test_health_does_not_contact_provider,   s     z:AbnAppContractChecks.test_health_does_not_contact_providerc                 C  sx   i t dddii}tjtdd d t|d\}}W d    n1 s%w   Y  | d| | d|d	 d
  d S )Nr   abn51824753556r'   r(   r#   i  credential_not_configurederrorcode)r2   r   r0   r   r1   r   )r   contextr   r-   r    r    r!   ,test_missing_credential_returns_stable_error3   s   zAAbnAppContractChecks.test_missing_credential_returns_stable_errorc              	   C  s   i t dddii}ddd}tjtddd& tjtd	|d}t|d
}W d    n1 s1w   Y  W d    n1 s@w   Y  |jdddd | ||d d  | dt| d S )Nr   r7   r8   Example)r7   entity_namer'   zsecret-guidr(   r*   r#   F)include_historyguidr.   record)	r2   r   r0   r   r1   assert_called_once_withr   assertNotInstr)r   r<   rB   r5   r   r    r    r!   1test_lookup_uses_vault_value_without_returning_it:   s   
 zFAbnAppContractChecks.test_lookup_uses_vault_value_without_returning_itc                 C  s0   t td}| d|d  | d|d  d S )Ntestr,   r-   r
   r   )r   r1   r2   r   )r   r   r    r    r!   %test_legacy_health_remains_compatibleE   s   z:AbnAppContractChecks.test_legacy_health_remains_compatibleN)	__name__
__module____qualname__r"   r&   r6   r=   rF   rH   r    r    r    r!   r      s    r   __main__)	verbosity)__doc__
__future__r   sysunittestpathlibr   unittest.mockr   __file__resolveparentsPROJECT_ROOTpathinsertrE   modulesgetloaded_platformhasattrapps.abn_lookup_appr
   r   #bridge_platform.agents.tool_catalogr   r2   TestCaser   rI   mainr    r    r    r!   <module>   s,    /