o
    '{\j	                     @  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
didi dZG dd dejZedkreejdd dS dS )z3Standalone ABN Lookup Standard v1 migration checks.    )annotationsN)Path)patch   platform__path__z	request-1	tenant_idztenant-aabn_lookup_app)
request_idtenantapp_idpayloadc                   @  s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )AbnAppContractChecksc                 C  s*   |  g tj  |  dtjd d S )N	lookup_v1zbusiness.au.abn.lookup)assertEqualappAPP_MANIFESTvalidateaction_for_capability)self r   D/var/www/html/flask_server/tests/platform/abn_app_contract_checks.py)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)r$   r   r"   r   r#   r   )r   contextr   r   r   r   r   ,test_missing_credential_returns_stable_error*   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   r)   r*   Example)r)   entity_namer   zsecret-guidr   r   r   F)include_historyguidr    record)	r$   r   r"   r   r#   assert_called_once_withr   assertNotInstr)r   r.   r4   r'   r   r   r   r   1test_lookup_uses_vault_value_without_returning_it1   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   r#   r$   r   )r   r   r   r   r   %test_legacy_health_remains_compatible<   s   z:AbnAppContractChecks.test_legacy_health_remains_compatibleN)__name__
__module____qualname__r   r(   r/   r8   r:   r   r   r   r   r      s    r   __main__)	verbosity)__doc__
__future__r   sysunittestpathlibr   unittest.mockr   __file__resolveparentsPROJECT_ROOTpathinsertr7   modulesgetloaded_platformhasattrapps.abn_lookup_appr	   r   r$   TestCaser   r;   mainr   r   r   r   <module>   s*    '