Ë
    daºioi  ã                   óf   — d dl Z d dlZd dlmZ ddlmZ  e j                  e«      Z G d„ de«      Z	y)é    N)Ú	HTTPErroré   )ÚAtlassianRestAPIc                   óv  ‡ — e Zd Zˆ fd„Zd„ Zd4d„Zd„ Zd„ Zd„ Z	 	 	 	 	 	 	 d5d„Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd4d„Zd„ Zd4d„Zd4d„Zd„ Zd4d„Zd4d„Zd„ Zd„ Zd4d„Zd„ Z d6d„Z!d4d „Z"d!„ Z#d"„ Z$d#„ Z%d$„ Z&d%„ Z'd&„ Z(d'„ Z)d(„ Z*d4d)„Z+d*„ Z,d+„ Z-d,„ Z.d-„ Z/d.„ Z0d7d/„Z1d8d0„Z2d1„ Z3d9d2„Z4d4d3„Z5ˆ xZ6S ):ÚXrayc                 óH   •— d|vrd|d<   d|d<   t        t        | �
  |i |¤Ž y )NÚapi_versionú1.0z
rest/ravenÚapi_root)Úsuperr   Ú__init__)ÚselfÚargsÚkwargsÚ	__class__s      €úF/var/www/timesheet/venv/lib/python3.12/site-packages/atlassian/xray.pyr   zXray.__init__   s3   ø€ Ø Ñ&Ø$)ˆF�=Ñ!Ø)ˆˆzÑÜŒd�DÑ" DÐ3¨FÓ3ó    c                 ód  — |j                   dk(  r+|j                  j                  d«      dk7  rt        d|¬«      ‚d|j                   cxk  rdk  r&n y		 |j	                  «       }|d   }t        ||¬«      ‚y	# t
        $ r/}t        j                  |«       |j                  «        Y d	}~y	d	}~ww xY w)
z©
        Checks the response for an error status and raises an exception with the error message provided by the server
        :param response:
        :return:
        i‘  zContent-Typezapplication/json;charset=UTF-8zUnauthorized (401))Úresponsei�  iX  ÚmessageN)	Ústatus_codeÚheadersÚgetr   ÚjsonÚ	ExceptionÚlogÚerrorÚraise_for_status)r   r   ÚjÚ	error_msgÚes        r   r   zXray.raise_for_status   s¥   € ð ×Ñ 3Ò&¨8×+;Ñ+;×+?Ñ+?ÀÓ+OÐSsÒ+sÜÐ0¸8ÔDÐDà�(×&Ñ&Ô,¨Õ,ð>Ø—M‘M“O�Ø˜i™L�	ô
   	°HÔ=Ð=ð -øô ò ,Ü—	‘	˜!”Ø×)Ñ)×+Ñ+ûð,ús   ÁA7 Á7	B/Â %B*Â*B/c                 ór   — |€| j                   }|€| j                  }dj                  d„ ||d|fD «       «      S )z{
        Overloading the method from AtlassianRestAPI to be compatible with the "middle man" version used by Xray.
        ú/c              3   óD   K  — | ]  }|€Œ|j                  d«      –— Œ y ­w)Nr#   )Ústrip)Ú.0Úss     r   ú	<genexpr>z$Xray.resource_url.<locals>.<genexpr>,   s   è ø€ Òh¨ÐZ[ÑZg˜Ÿ™ ŸÑhùs   ‚ Š Úapi)r   r	   Újoin)r   Úresourcer   r	   s       r   Úresource_urlzXray.resource_url$   sB   € ð ÐØ—}‘}ˆHØÐØ×*Ñ*ˆKØ�x‰xÑh¨x¸ÀeÈXÐ.VÔhÓhÐhr   c                 ój   — | j                  ddj                  |«      › �«      }| j                  |«      S )zÄ
        Retrieve information about the provided tests.
        :param test_keys: list of tests (eg. `['TEST-001', 'TEST-002']`) to retrieve.
        :return: Returns the retrieved tests.
        z
test?keys=ú;)r,   r*   r   )r   Ú	test_keysÚurls      r   Ú	get_testszXray.get_tests/   s3   € ð ×Ñ *¨S¯X©X°iÓ-@Ð,AÐ BÓCˆØ�x‰x˜‹}Ðr   c                 óF   — | j                  d«      }| j                  |«      S )z„
        Retrieve a list of all Test Statuses available in Xray sorted by rank.
        :return: Returns the test statuses.
        zsettings/teststatuses©r,   r   ©r   r0   s     r   Úget_test_statuseszXray.get_test_statuses8   s#   € ð
 ×ÑÐ 7Ó8ˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z”
        Retrieve test runs of a test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Returns the exported test runs.
        útest/ú	/testrunsr3   ©r   Útest_keyr0   s      r   Úget_test_runszXray.get_test_runs@   ó+   € ð ×Ñ %¨ z°Ð ;Ó<ˆØ�x‰x˜‹}Ðr   c                 óä   — | j                   dk(  rt        d«      ‚i }|r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |r||d<   |r||d	<   | j                  d
«      }	| j                  |	|¬«      S )aÏ  
        Retrieves all the Test Runs from a given context.
        With this endpoint you can obtain all the Test Runs (paginated)
        in one of the following contexts:
        * In a Test Execution issue (use testKey to limit to single test)
        * In a Test Plan issue
        * In a JQL filter that returns several Test Execution issue
        In case the Test Run has iterations, steps will not appear.
        However, if the Test has parameters but executed one time,
        it will show the steps and the parameters' info
        :param test_exec_key: The Test Execution issue key
        :param test_key: The Test issue key
        (may only be used when using the "test_exec_key" param)
        :param test_plan_key: The Test Plan issue key
        :param include_test_fields: List of custom fields of the Test issue
        to be return in the responde
        (several custom fields can be requested by separating them with ',')
        :param saved_filter_id: The Jira JQL filter ID or
        name containing Test Executions issues
        :param limit: The number of maximum Test Runs to be returned
        :param page: The number of the results page
        :return: Returns the exported test runs.
        r
   z Not supported in API version 1.0ÚtestExecKeyÚtestKeyÚtestPlanKeyÚincludeTestFieldsÚsavedFilterIdÚlimitÚpageÚtestruns©Úparams)r	   r   r,   r   )
r   Útest_exec_keyr:   Útest_plan_keyÚinclude_test_fieldsÚsaved_filter_idrC   rD   rG   r0   s
             r   Úget_test_runs_in_contextzXray.get_test_runs_in_contextI   s¡   € ðB ×Ñ˜uÒ$ÜÐ>Ó?Ð?ØˆÙØ$1ˆF�=Ñ!ÙØ (ˆF�9ÑÙØ$1ˆF�=Ñ!ÙØ*=ˆFÐ&Ñ'ÙØ&5ˆF�?Ñ#ÙØ#ˆF�7‰OÙØ!ˆF�6‰NØ×Ñ 
Ó+ˆØ�x‰x˜ FˆxÓ+Ð+r   c           	      óÆ   — ddj                  |D �cg c]  }t        j                  |«      ‘Œ c}«      › �}| j                  d|› d|› �«      }| j	                  |«      S c c}w )a  
        Retrieve test runs of a test filtered by tests environments.
        :param test_key: Test key (eg. 'TEST-001').
        :param test_environments: Test execution environments separated by ','.
        :return: Returns the exported test runs.
        z?testEnvironments=ú,r7   r8   )r*   ÚreÚescaper,   r   )r   r:   Útest_environmentsÚenvr0   s        r   Úget_test_runs_with_environmentz#Xray.get_test_runs_with_environment~   s_   € ð # 3§8¡8ÐGXÖ,YÀ¬R¯Y©Y°s­^Ò,YÓ#ZÐ"[Ð\ˆØ×Ñ %¨ z°¸3¸%Ð @ÓAˆØ�x‰x˜‹}Ðùò -Zs   ‘A
c                 óN   — | j                  d|› d�«      }| j                  |«      S )zª
        Retrieve pre-conditions of a test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Returns the test pre-conditions of a given test.
        r7   z/preconditionsr3   r9   s      r   Úget_test_preconditionszXray.get_test_preconditionsŠ   s+   € ð ×Ñ %¨ z°Ð @ÓAˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z¡
        Retrieve test sets associated with a test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Returns the exported test sets.
        r7   z	/testsetsr3   r9   s      r   Úget_test_setszXray.get_test_sets“   r<   r   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z 
        Retrieve test executions of a test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Returns the exported test executions.
        r7   z/testexecutionsr3   r9   s      r   Úget_test_executionszXray.get_test_executionsœ   s+   € ð ×Ñ %¨ z°Ð AÓBˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z£
        Retrieve test plans associated with a test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Returns the exported test plans.
        r7   z
/testplansr3   r9   s      r   Úget_test_planszXray.get_test_plans¥   s+   € ð ×Ñ %¨ z°Ð <Ó=ˆØ�x‰x˜‹}Ðr   c                 óF   — | j                  d«      }| j                  |«      S )z¥
        Retrieve the test step statuses available in Xray sorted by rank.
        :return: Returns the test step statuses available in Xray sorted by rank.
        zsettings/teststepstatusesr3   r4   s     r   Úget_test_step_statuseszXray.get_test_step_statuses¯   s#   € ð
 ×ÑÐ ;Ó<ˆØ�x‰x˜‹}Ðr   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )zâ
        Retrieve the specified test step of a given test.
        :param test_key: Test key (eg. 'TEST-001').
        :param test_step_id: ID of the test step.
        :return: Return the test step with the given id.
        r7   ú/step/r3   ©r   r:   Útest_step_idr0   s       r   Úget_test_stepzXray.get_test_step·   s/   € ð ×Ñ %¨ z°¸°~Ð FÓGˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z¦
        Retrieve the test steps of a given test.
        :param test_key: Test key (eg. 'TEST-001').
        :return: Return the test steps of a given test.
        r7   ú/stepr3   r9   s      r   Úget_test_stepszXray.get_test_stepsÁ   s+   € ð ×Ñ %¨ z°Ð 7Ó8ˆØ�x‰x˜‹}Ðr   c                 ó^   — |||g dœ}| j                  d|› d�«      }| j                  ||«      S )am  
        Create a new test steps for a given test.
        NOTE: attachments are currently not supported!
        :param test_key: Test key (eg. 'TEST-001').
        :param step: Test Step name (eg. 'Example step').
        :param data: Test Step data (eg. 'Example data').
        :param result: Test Step results (eg. 'Example results').
        :return:
        ©ÚstepÚdataÚresultÚattachmentsr7   rd   ©r,   Úput)r   r:   rh   ri   rj   Úcreater0   s          r   Úcreate_test_stepzXray.create_test_stepÊ   s<   € ð ¨¸ÈrÑRˆØ×Ñ %¨ z°Ð 7Ó8ˆØ�x‰x˜˜VÓ$Ð$r   c                 óh   — |||g g dœdœ}| j                  d|› d|› �«      }| j                  ||«      S )a§  
        Update the specified test steps for a given test.
        NOTE: attachments are currently not supported!
        :param test_key: Test key (eg. 'TEST-001').
        :param test_step_id: ID of the test step.
        :param step: Test Step name (eg. 'Example step').
        :param data: Test Step data (eg. 'Example data').
        :param result: Test Step results (eg. 'Example results').
        :return:
        ©ÚaddÚremoverg   r7   r_   ©r,   Úpost)r   r:   ra   rh   ri   rj   Úupdater0   s           r   Úupdate_test_stepzXray.update_test_stepØ   sL   € ð ØØØ#%°Ñ4ñ	
ˆð ×Ñ %¨ z°¸°~Ð FÓGˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )z»
        Remove the specified test steps from a given test.
        :param test_key: Test key (eg. 'TEST-001').
        :param test_step_id: ID of the test step.
        :return:
        r7   r_   ©r,   Údeleter`   s       r   Údelete_test_stepzXray.delete_test_stepì   s0   € ð ×Ñ %¨ z°¸°~Ð FÓGˆØ�{‰{˜3ÓÐr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )zß
        Retrieve the tests associated with the given pre-condition.
        :param precondition_key: Precondition key (eg. 'TEST-001').
        :return: Return a list of the test associated with the pre-condition.
        úprecondition/ú/testr3   )r   Úprecondition_keyr0   s      r   Úget_tests_with_preconditionz Xray.get_tests_with_precondition÷   s-   € ð ×Ñ -Ð0@Ð/AÀÐ GÓHˆØ�x‰x˜‹}Ðr   c                 ój   — |€g }|€g }||dœ}| j                  d|› d�«      }| j                  ||«      S )a|  
        Associate tests with the given pre-condition.
        :param precondition_key: Precondition key (eg. 'TEST-001').
        :param add: OPTIONAL: List of Test Keys to associate with the pre-condition (eg. ['TEST-2', 'TEST-3'])
        :param remove: OPTIONAL: List of Test Keys no longer associate with the pre-condition (eg. ['TEST-4', 'TEST-5'])
        :return:
        rq   r}   r~   rt   )r   r   rr   rs   rv   r0   s         r   Úupdate_preconditionzXray.update_precondition   sN   € ð ˆ>ØˆFØˆ;ØˆCØ¨Ñ/ˆØ×Ñ -Ð0@Ð/AÀÐ GÓHˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a  
        Remove association of the specified tests from the given pre-condition.
        :param precondition_key: Precondition key (eg. 'TEST-001').
        :param test_key: Test Key which should no longer be associate with the pre-condition (eg. 'TEST-100')
        :return:
        r}   ú/test/ry   )r   r   r:   r0   s       r   Údelete_test_from_preconditionz"Xray.delete_test_from_precondition  s2   € ð ×Ñ -Ð0@Ð/AÀÈÀzÐ RÓSˆØ�{‰{˜3ÓÐr   c                 ór   — | j                  d|› d�«      }i }|r||d<   |r||d<   | j                  ||¬«      S )aU  
        Retrieve the tests associated with the given test set.
        :param test_set_key: Test set key (eg. 'SET-001').
        :param limit: OPTIONAL: Limits the number of results per page.
        :param page: OPTIONAL: Number of the page to be returned.
        :return: Return a list of the test associated with the test set.
        útestset/r~   rC   rD   rF   r3   )r   Útest_set_keyrC   rD   r0   rG   s         r   Úget_tests_with_test_setzXray.get_tests_with_test_set  sM   € ð ×Ñ (¨<¨.¸Ð >Ó?ˆØˆáØ#ˆF�7‰OÙØ!ˆF�6‰Nà�x‰x˜ FˆxÓ+Ð+r   c                 ój   — |€g }|€g }||dœ}| j                  d|› d�«      }| j                  ||«      S )al  
        Associate tests with the given test set.
        :param test_set_key: Test set key (eg. 'SET-001').
        :param add: OPTIONAL: List of Test Keys to associate with the test set (eg. ['TEST-002', 'TEST-003'])
        :param remove: OPTIONAL: List of Test Keys no longer associate with the test set (eg. ['TEST-004', 'TEST-005'])
        :return:
        rq   r‡   r~   rt   )r   rˆ   rr   rs   rv   r0   s         r   Úupdate_test_setzXray.update_test_set-  sL   € ð ˆ;ØˆCØˆ>ØˆFØ¨Ñ/ˆØ×Ñ (¨<¨.¸Ð >Ó?ˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a	  
        Remove association of the specified tests from the given test set.
        :param test_set_key: Test set key (eg. 'SET-001').
        :param test_key: Test Key which should no longer be associate with the test set (eg. 'TEST-100')
        :return:
        r‡   r„   ry   )r   rˆ   r:   r0   s       r   Údelete_test_from_test_setzXray.delete_test_from_test_set=  s0   € ð ×Ñ (¨<¨.¸¸x¸jÐ IÓJˆØ�{‰{˜3ÓÐr   c                 ór   — | j                  d|› d�«      }i }|r||d<   |r||d<   | j                  ||¬«      S )aY  
        Retrieve the tests associated with the given test plan.
        :param test_plan_key: Test set key (eg. 'PLAN-001').
        :param limit: OPTIONAL: Limits the number of results per page.
        :param page: OPTIONAL: Number of the page to be returned.
        :return: Return a list of the test associated with the test plan.
        ú	testplan/r~   rC   rD   rF   r3   )r   rI   rC   rD   r0   rG   s         r   Úget_tests_with_test_planzXray.get_tests_with_test_planH  sM   € ð ×Ñ )¨M¨?¸%Ð @ÓAˆØˆáØ#ˆF�7‰OÙØ!ˆF�6‰Nà�x‰x˜ FˆxÓ+Ð+r   c                 ój   — |€g }|€g }||dœ}| j                  d|› d�«      }| j                  ||«      S )ar  
        Associate tests with the given test plan.
        :param test_plan_key: Test plan key (eg. 'PLAN-001').
        :param add: OPTIONAL: List of Test Keys to associate with the test plan (eg. ['TEST-002', 'TEST-003'])
        :param remove: OPTIONAL: List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
        :return:
        rq   r�   r~   rt   ©r   rI   rr   rs   rv   r0   s         r   Úupdate_test_planzXray.update_test_planZ  sL   € ð ˆ;ØˆCØˆ>ØˆFØ¨Ñ/ˆØ×Ñ )¨M¨?¸%Ð @ÓAˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a  
        Remove association of the specified tests from the given test plan.
        :param test_plan_key: Test plan key (eg. 'PLAN-001').
        :param test_key: Test Key which should no longer be associate with the test plan (eg. 'TEST-100')
        :return:
        r�   r„   ry   )r   rI   r:   r0   s       r   Údelete_test_from_test_planzXray.delete_test_from_test_planj  ó0   € ð ×Ñ )¨M¨?¸&ÀÀ
Ð KÓLˆØ�{‰{˜3ÓÐr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )zâ
        Retrieve test executions associated with the given test plan.
        :param test_plan_key: Test plan key (eg. 'PLAN-001').
        :return: Return a list of the test executions associated with the test plan.
        r�   ú/testexecutionr3   )r   rI   r0   s      r   Ú"get_test_executions_with_test_planz'Xray.get_test_executions_with_test_plant  s+   € ð ×Ñ )¨M¨?¸.Ð IÓJˆØ�x‰x˜‹}Ðr   c                 ój   — |€g }|€g }||dœ}| j                  d|› d�«      }| j                  ||«      S )a|  
        Associate test executions with the given test plan.
        :param test_plan_key: Test plan key (eg. 'PLAN-001').
        :param add: OPTIONAL: List of Test Keys to associate with the test plan (eg. ['TEST-002', 'TEST-003'])
        :param remove: OPTIONAL: List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
        :return:
        rq   r�   r˜   rt   r’   s         r   Ú update_test_plan_test_executionsz%Xray.update_test_plan_test_executions}  sL   € ð ˆ;ØˆCØˆ>ØˆFØ¨Ñ/ˆØ×Ñ )¨M¨?¸.Ð IÓJˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a'  
        Remove association of the specified tests execution from the given test plan.
        :param test_plan_key: Test plan key (eg. 'PLAN-001').
        :param test_exec_key: Test execution Key which should no longer be associate with the test plan (eg. 'TEST-100')
        :return:
        r�   z/testexecution/ry   )r   rI   rH   r0   s       r   Ú$delete_test_execution_from_test_planz)Xray.delete_test_execution_from_test_plan�  s0   € ð ×Ñ )¨M¨?¸/È-ÈÐ YÓZˆØ�{‰{˜3ÓÐr   c                 ó€   — | j                  d|› d�«      }i }|r||d<   |r||d<   |r||d<   | j                  ||¬«      S )aÃ  
        Retrieve the tests associated with the given test execution.
        :param test_exec_key: Test execution key (eg. 'EXEC-001').
        :param detailed: OPTIONAL: (bool) Retrieve detailed information about the testrun
        :param limit: OPTIONAL: Limits the number of results per page.
        :param page: OPTIONAL: Number of the page to be returned.
        :return: Return a list of the test associated with the test execution.
        ú	testexec/r~   ÚdetailedrC   rD   rF   r3   )r   rH   r    rC   rD   r0   rG   s          r   Úget_tests_with_test_executionz"Xray.get_tests_with_test_execution˜  sZ   € ð ×Ñ )¨M¨?¸%Ð @ÓAˆØˆáØ!)ˆF�:ÑÙØ#ˆF�7‰OÙØ!ˆF�6‰Nà�x‰x˜ FˆxÓ+Ð+r   c                 ój   — |€g }|€g }||dœ}| j                  d|› d�«      }| j                  ||«      S )aŠ  
        Associate tests with the given test execution.
        :param test_exec_key: Test execution key (eg. 'EXEC-001').
        :param add: OPTIONAL: List of Test Keys to associate with the test execution (eg. ['TEST-2', 'TEST-3'])
        :param remove: OPTIONAL:
            List of Test Keys no longer associate with the test execution (eg. ['TEST-4', 'TEST-5'])
        :return:
        rq   rŸ   r~   rt   )r   rH   rr   rs   rv   r0   s         r   Úupdate_test_executionzXray.update_test_execution­  sL   € ð ˆ;ØˆCØˆ>ØˆFØ¨Ñ/ˆØ×Ñ )¨M¨?¸%Ð @ÓAˆØ�y‰y˜˜fÓ%Ð%r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a  
        Remove association of the specified tests from the given test execution.
        :param test_exec_key: Test execution key (eg. 'EXEC-001').
        :param test_key: Test Key which should no longer be associate with the test execution (eg. 'TEST-100')
        :return:
        rŸ   r„   ry   )r   rH   r:   r0   s       r   Údelete_test_from_test_executionz$Xray.delete_test_from_test_execution¾  r–   r   c                 óL   — | j                  d|› �«      }| j                  |«      S )zÆ
        Retrieve detailed information about the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns detailed information about the test run.
        útestrun/r3   ©r   Útest_run_idr0   s      r   Úget_test_runzXray.get_test_runÉ  s)   € ð ×Ñ (¨;¨-Ð 8Ó9ˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z·
        Retrieve the assignee for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns the assignee for the given test run
        r§   z	/assigneer3   r¨   s      r   Úget_test_run_assigneezXray.get_test_run_assigneeÒ  s+   € ð ×Ñ (¨;¨-°yÐ AÓBˆØ�x‰x˜‹}Ðr   c                 óV   — d|i}| j                  d|› �«      }| j                  ||«      S )z¹
        Update the assignee for the given test run.
        :param test_run_id: ID of the test run (eg. 100).
        :param assignee: Assignee id (eg. 'bob')
        :return:
        Úassigneer§   rl   )r   r©   r®   rv   r0   s        r   Úupdate_test_run_assigneezXray.update_test_run_assigneeÛ  s6   € ð ˜hÐ'ˆØ×Ñ (¨;¨-Ð 8Ó9ˆØ�x‰x˜˜VÓ$Ð$r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )a   
        Retrieve the specified iteration for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :param iteration_id: ID of the iteration.
        :return: Returns the specified iteration for the given test run.
        r§   z/iteration/r3   )r   r©   Úiteration_idr0   s       r   Úget_test_run_iterationzXray.get_test_run_iterationæ  s/   € ð ×Ñ (¨;¨-°{À<À.Ð QÓRˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z³
        Retrieve the status for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns the status for the given test run
        r§   z/statusr3   r¨   s      r   Úget_test_run_statuszXray.get_test_run_statusð  ó+   € ð ×Ñ (¨;¨-°wÐ ?Ó@ˆØ�x‰x˜‹}Ðr   c                 óV   — d|i}| j                  d|› �«      }| j                  ||«      S )zµ
        Update the status for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :param status: Status id (eg. 'PASS')
        :return:
        Ústatusr§   rl   )r   r©   r·   rv   r0   s        r   Úupdate_test_run_statuszXray.update_test_run_statusù  s6   € ð ˜FÐ#ˆØ×Ñ (¨;¨-Ð 8Ó9ˆØ�x‰x˜˜VÓ$Ð$r   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z»
        Retrieve the defects for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns a list of defects for the given test run
        r§   z/defectr3   r¨   s      r   Úget_test_run_defectszXray.get_test_run_defects  rµ   r   c                 ól   — |€g }|€g }d||dœi}| j                  d|› �«      }| j                  ||«      S )at  
        Update the defects associated with the given test run.
        :param test_run_id: ID of the test run (eg. 100).
        :param add: OPTIONAL: List of defects to associate to the test run (eg. ['BUG-001', 'BUG-002'])
        :param remove: OPTIONAL: List of defects which no longer need to be associated to the test run (eg. ['BUG-003'])
        :return:
        Údefectsrq   r§   rl   )r   r©   rr   rs   rv   r0   s         r   Úupdate_test_run_defectszXray.update_test_run_defects  sO   € ð ˆ;ØˆCØˆ>ØˆFØ S°FÑ;Ð<ˆØ×Ñ (¨;¨-Ð 8Ó9ˆØ�x‰x˜˜VÓ$Ð$r   c                 óN   — | j                  d|› d�«      }| j                  |«      S )zµ
        Retrieve the comment for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns the comment for the given test run
        r§   z/commentr3   r¨   s      r   Úget_test_run_commentzXray.get_test_run_comment  s+   € ð ×Ñ (¨;¨-°xÐ @ÓAˆØ�x‰x˜‹}Ðr   c                 óV   — d|i}| j                  d|› �«      }| j                  ||«      S )zÊ
        Update the comment for the given test run.
        :param test_run_id: ID of the test run (eg. 100).
        :param comment: Comment (e.g. 'Test needs to be reworked')
        :return:
        Úcommentr§   rl   )r   r©   rÁ   rv   r0   s        r   Úupdate_test_run_commentzXray.update_test_run_comment&  s6   € ð ˜WÐ%ˆØ×Ñ (¨;¨-Ð 8Ó9ˆØ�x‰x˜˜VÓ$Ð$r   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z±
        Retrieve the steps for the given test run.
        :param test_run_id: ID of the test run (e.g. 100).
        :return: Returns the steps for the given test run
        r§   rd   r3   r¨   s      r   Úget_test_run_stepszXray.get_test_run_steps1  s+   € ð ×Ñ (¨;¨-°uÐ =Ó>ˆØ�x‰x˜‹}Ðr   c                 óN   — | j                  d|› d�«      }| j                  |«      S )z³
        Retrieve test repository folders of a project.
        :param project_key: Project key (eg. 'FOO').
        :return: Returns the list of test repository folders.
        útestrepository/z/foldersr3   )r   Úproject_keyr0   s      r   Úget_test_repo_folderszXray.get_test_repo_folders:  s+   € ð ×Ñ /°+°¸hÐ GÓHˆØ�x‰x˜‹}Ðr   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )z×
        Retrieve test repository folder of a project.
        :param project_key: Project key (eg. 'FOO').
        :param folder_id: Internal folder ID.
        :return: Returns the test repository folder.
        rÆ   ú	/folders/r3   ©r   rÇ   Ú	folder_idr0   s       r   Úget_test_repo_folderzXray.get_test_repo_folderC  s/   € ð ×Ñ /°+°¸iÈ	À{Ð SÓTˆØ�x‰x˜‹}Ðr   c                 ó^   — d|i}| j                  d|› d|› �«      }| j                  ||¬«      S )aM  
        Create test repository folder for a project.
        :param project_key: Project key (eg. 'FOO').
        :param folder_name: Name of folder.
        :param parent_folder_id: Internal folder ID; "-1" corresponds to the root folder of the test repository.
        :return: Returns the created test repository folder.
        ÚnamerÆ   rÊ   ©ri   rt   )r   rÇ   Úfolder_nameÚparent_folder_idri   r0   s         r   Úcreate_test_repo_folderzXray.create_test_repo_folderM  s@   € ð ˜Ð$ˆØ×Ñ /°+°¸iÐHXÐGYÐ ZÓ[ˆØ�y‰y˜ 4ˆyÓ(Ð(r   c                 ó`   — ||dœ}| j                  d|› d|› �«      }| j                  ||¬«      S )a>  
        Update test repository folder for a project.
        :param project_key: Project key (eg. 'FOO').
        :param folder_id: Internal folder ID.
        :param folder_name: Name of folder.
        :param rank: Rank within the parent folder.
        :return: Returns the updated test repository folder.
        )rÏ   ÚrankrÆ   rÊ   rÐ   rl   )r   rÇ   rÌ   rÑ   rÕ   ri   r0   s          r   Úupdate_test_repo_folderzXray.update_test_repo_folderY  s>   € ð $¨TÑ2ˆØ×Ñ /°+°¸iÈ	À{Ð SÓTˆØ�x‰x˜ $ˆxÓ'Ð'r   c                 óR   — | j                  d|› d|› �«      }| j                  |«      S )zÎ
        Delete test repository folder for a project.
        :param project_key: Project key (eg. 'FOO').
        :param folder_id: Internal folder Id.
        :return: Returns the delete results.
        rÆ   rÊ   ry   rË   s       r   Údelete_test_repo_folderzXray.delete_test_repo_folderf  s0   € ð ×Ñ /°+°¸iÈ	À{Ð SÓTˆØ�{‰{˜3ÓÐr   c                 ó†   — | j                  d|› d|› d�«      }i }|r||d<   |r||d<   |r||d<   | j                  ||¬«      S )a+  
        Retrieve tests of a test repository folder.
        :param project_key: Project key (eg. 'FOO').
        :param folder_id: Internal folder ID.
        :param all_descendants: Include all descendants (i.e. all child Tests); "false", by default.
        :param page: Page of paginated data (first 1)
        :param limit: Amount of Tests per paginated data.
        :return: Returns list of the Tests contained in a given folder of the test repository.
        Note: param "page" and "limit" must coexist, otherwise rest api will raise 400
        rÆ   rÊ   ú/testsÚallDescendantsrD   rC   rF   r3   )r   rÇ   rÌ   Úall_descendantsrD   rC   r0   rG   s           r   Úget_test_repo_folder_testszXray.get_test_repo_folder_testsp  sb   € ð ×Ñ /°+°¸iÈ	À{ÐRXÐ YÓZˆØˆáØ'6ˆFÐ#Ñ$ÙØ!ˆF�6‰NÙØ#ˆF�7‰Oà�x‰x˜ FˆxÓ+Ð+r   c                 ór   — |€g }|€g }||dœ}| j                  d|› d|› d�«      }| j                  ||¬«      S )aq  
        Update tests of a test repository folder.
        :param project_key: Project key (eg. 'FOO').
        :param folder_id: Internal folder Id.
        :param add: OPTIONAL: List of tests to be added (eg. ['TEST-001', 'TEST-002'])
        :param remove: OPTIONAL: List of tests to be removed (eg. ['TEST-003'])
        :return: Returns the update result.
        rq   rÆ   rÊ   rÚ   rÐ   rl   )r   rÇ   rÌ   rr   rs   ri   r0   s          r   Úupdate_test_repo_folder_testsz"Xray.update_test_repo_folder_tests‡  sU   € ð ˆ;ØˆCØˆ>ØˆFØ fÑ-ˆØ×Ñ /°+°¸iÈ	À{ÐRXÐ YÓZˆØ�x‰x˜ $ˆxÓ'Ð'r   )NN)NNNNNNN)FNN)éÿÿÿÿ)r   )Fr   é2   )7Ú__name__Ú
__module__Ú__qualname__r   r   r,   r1   r5   r;   rL   rS   rU   rW   rY   r[   r]   rb   re   ro   rw   r{   r€   r‚   r…   r‰   r‹   r�   r�   r“   r•   r™   r›   r�   r¡   r£   r¥   rª   r¬   r¯   r²   r´   r¸   rº   r½   r¿   rÂ   rÄ   rÈ   rÍ   rÓ   rÖ   rØ   rÝ   rß   Ú__classcell__)r   s   @r   r   r   
   s  ø„ ô4ò>ó&iòòòð ØØØ ØØØó3,òj
òòòòòòòò%ò&ò( òó&ò  ó,ó$&ò  ó,ó$&ò  òó&ò  ó,ó*&ò" òòò	%òòò	%òó%ò ò	%òòòó
)ó(ò ó,÷.(r   r   )
ÚloggingrO   Úrequestsr   Úrest_clientr   Ú	getLoggerrâ   r   r   © r   r   ú<module>rë      s2   ðã Û 	Ý Ý )à€g×Ñ˜Ó!€ôL
(Ðõ L
(r   