o
    i                     @   s   d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZ d dlmZ eeZG d	d
 d
eZG dd dZG dd dZdS )    )EnumN)TestId)_catch_and_log_exceptions)TestExcInfo)
TestStatus)require_ci_visibility_service)
get_loggerc                   @   s   e Zd ZdZdZdZdZdS )EFDTestStatuspassedfailedskippedflakyN)__name__
__module____qualname__ALL_PASSALL_FAILALL_SKIPFLAKY r   r   `/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/internal/test_visibility/_efd_mixins.pyr	      s
    r	   c                   @   sN   e Zd ZeedefddZeedefddZeedefddZdS )	EFDSessionMixinreturnc                   C      t d t   S )NzChecking if EFD is enabled)logdebugr   get_sessionefd_is_enabledr   r   r   r   efd_enabled      
zEFDSessionMixin.efd_enabledc                   C   r   )Nz!Checking if EFD session is faulty)r   r   r   r   efd_is_faulty_sessionr   r   r   r   r       r   z%EFDSessionMixin.efd_is_faulty_sessionc                   C   r   )Nz(Checking if EFD session has failed tests)r   r   r   r   efd_has_failed_testsr   r   r   r   r!   %   r   z$EFDSessionMixin.efd_has_failed_testsN)	r   r   r   staticmethodr   boolr   r    r!   r   r   r   r   r      s    r   c                   @   s   e Zd ZeededefddZeeddededej	e
 fddZeeded	e
dd
fddZee	
	
dded	e
dedej	e dej	e f
ddZeededefddZd
S )EFDTestMixinitem_idr   c                 C      t d|  t |  S )Nz,Checking if test %s should be retried by EFD)r   r   r   get_test_by_idefd_should_retryr%   r   r   r   r(   .      zEFDTestMixin.efd_should_retryFstart_immediatelyc                 C   s$   t  | |}td||  |S )NzAdding EFD retry %s for test %s)r   r'   efd_add_retryr   r   )r%   r+   retry_numberr   r   r   r,   5   s   zEFDTestMixin.efd_add_retryr-   Nc                 C   s$   t d||  t | | d S )Nz!Starting EFD retry %s for test %s)r   r   r   r'   efd_start_retry)r%   r-   r   r   r   r.   <   s   zEFDTestMixin.efd_start_retrystatusskip_reasonexc_infoc                 C   s2   t d|| ||| t | j||||d d S )NzRFinishing EFD test retry %s for item %s, status: %s, skip_reason: %s, exc_info: %s)r-   r/   r0   r1   )r   r   r   r'   efd_finish_retry)r%   r-   r/   r0   r1   r   r   r   r2   C   s   	
zEFDTestMixin.efd_finish_retryc                 C   r&   )Nz$Getting EFD final status for test %s)r   r   r   r'   efd_get_final_statusr)   r   r   r   r3   X   r*   z!EFDTestMixin.efd_get_final_status)F)NN)r   r   r   r"   r   r   r#   r(   tOptionalintr,   r.   r   strr   r2   r	   r3   r   r   r   r   r$   -   s8    "r$   )enumr   typingr4   1ddtrace.ext.test_visibility._test_visibility_baser   "ddtrace.ext.test_visibility._utilsr   "ddtrace.ext.test_visibility.statusr   r   /ddtrace.internal.ci_visibility.service_registryr   ddtrace.internal.loggerr   r   r   r	   r   r$   r   r   r   r   <module>   s    