o
    Ďi	                     @   s   d dl Z d dlZd dlZd dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZ eed eedZe eZW d   n1 sDw   Y  G dd	 d	ejZdS )
    N)Path)load_dotenv)KeypointDetectionModel)PredictionGroupz
../../.envzMtests/annotations/keypoint-detection-annotations/MM2A_46_R_T_predictions.jsonc                       s   e Zd ZeddZedZedZdZde de Z	edd	d
Z
 fddZdd Zejdd Zejdd Zejdd Z  ZS )TestKeypointDetectionROBOFLOW_API_KEYztest-api-keyWORKSPACE_IDPROJECT_NAME1https://detect.roboflow.com//40zYOUR_IMAGE.jpg)api_key
confidencenamec                    s*   t    | j d| j d| j | _d S )Nr   )supersetUp	workspace
dataset_idversion
version_id)self	__class__ `/home/jeff/fluffinator/venv/lib/python3.10/site-packages/tests/models/test_keypoint_detection.pyr      s   
 zTestKeypointDetection.setUpc                 C   sF   t | j| j| jd}| |j| j | |j| j | |jd d S )Nr   r   )r   r   r   r   assertEqualidbase_urlr   instancer   r   r   test_init_sets_attributes!   s   z/TestKeypointDetection.test_init_sets_attributesc                 C   sV   t | j| j| jd}tjtj| jtdd |	d}| 
|t | t|jd d S )Nr      jsonstatustests/images/MM2A_46_R_T.png   )r   r   r   r   	responsesaddPOSTapi_urlMOCK_RESPONSEpredictassertIsInstancer   r   lenpredictions)r   r!   resultr   r   r   test_predict_local_image(   s
   
z.TestKeypointDetection.test_predict_local_imagec                 C   sf   t | j| j| jd}tjtj| jtdd |j	ddd}| 
|t tjd j}| |jd d	 d S )
Nr   r#   r$   r'      )r   r   r   30)r   r   r   r   r)   r*   r+   r,   r-   r.   r/   r   callsrequestr   params)r   r!   r2   r7   r   r   r   test_predict_with_confidence3   s   z2TestKeypointDetection.test_predict_with_confidencec                 C   sh   t | j| j| jd}tjtj| jddidd | t	 |
d W d    d S 1 s-w   Y  d S )Nr   errorzInvalid API keyi  r$   r'   )r   r   r   r   r)   r*   r+   r,   assertRaises	Exceptionr.   r    r   r   r   test_predict_error_response?   s
   "z1TestKeypointDetection.test_predict_error_response)__name__
__module____qualname__osgetenvr   r   r   r   r,   _default_paramsr   r"   r)   activater3   r9   r=   __classcell__r   r   r   r   r      s    




r   )r%   rA   unittestpathlibr   r)   dotenvr   "roboflow.models.keypoint_detectionr   roboflow.util.predictionr   openfloadr-   TestCaser   r   r   r   r   <module>   s    