o
    i
                     @   s   d dl 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e jG dd	 d	ZG d
d dZG dd dZdS )    N)TestId)_catch_and_log_exceptions)TestExcInfo)
TestStatus)require_ci_visibility_service)
get_loggerc                   @   s2   e Zd ZU dZeed< dZeed< dZeed< dS )AutoTestRetriesSettingsFenabled   max_retriesi  max_session_total_retriesN)	__name__
__module____qualname__r	   bool__annotations__r   intr    r   r   `/home/ubuntu/.local/lib/python3.10/site-packages/ddtrace/internal/test_visibility/_atr_mixins.pyr      s   
 r   c                   @   s8   e Zd ZeedefddZeedefddZdS )ATRSessionMixinreturnc                   C   s   t d t  S )NzChecking if ATR is enabled)logdebugr   is_atr_enabledr   r   r   r   atr_is_enabled   s   

zATRSessionMixin.atr_is_enabledc                   C   s   t d t   S )Nz(Checking if ATR session has failed tests)r   r   r   get_sessionatr_has_failed_testsr   r   r   r   r      s   
z$ATRSessionMixin.atr_has_failed_testsN)r   r   r   staticmethodr   r   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 dd
fddZeededefddZd
S )ATRTestMixinitem_idr   c                 C      t d|  t |  S )Nz,Checking if test %s should be retried by ATR)r   r   r   get_test_by_idatr_should_retry)r   r   r   r   r"   %   s   zATRTestMixin.atr_should_retryFstart_immediatelyc                 C   s$   t  | |}td||  |S )NzAdding ATR retry %s for test %s)r   r!   atr_add_retryr   r   )r   r#   retry_numberr   r   r   r$   +   s   zATRTestMixin.atr_add_retryr%   Nc                 C   s$   t d||  t | | d S )Nz!Starting ATR retry %s for test %s)r   r   r   r!   atr_start_retry)r   r%   r   r   r   r&   2   s   zATRTestMixin.atr_start_retrystatusskip_reasonexc_infoc                 C   s,   t d||  t | j||||d d S )Nz"Finishing ATR retry %s for test %s)r%   r'   r(   r)   )r   r   r   r!   atr_finish_retry)r   r%   r'   r(   r)   r   r   r   r*   8   s   	
zATRTestMixin.atr_finish_retrytest_idc                 C   r    )Nz$Getting ATR final status for test %s)r   r   r   r!   atr_get_final_status)r+   r   r   r   r,   F   s   z!ATRTestMixin.atr_get_final_status)F)NN)r   r   r   r   r   r   r   r"   tOptionalr   r$   r&   r   strr   r*   r,   r   r   r   r   r   $   s<    "r   )dataclassestypingr-   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   	dataclassr   r   r   r   r   r   r   <module>   s    