Esempio n. 1
0
 def add_result(self, test_id: ModelID, result: Result) -> Result:
     """http://docs.gurock.com/testrail-api2/reference-results#add_result"""
     new_result_data = result.to_json(include_none=False)
     result_data = self._request(f'add_result/{test_id}',
                                 method='POST',
                                 data=new_result_data)
     return Result.from_json(data_json=result_data)
Esempio n. 2
0
def test_add_results_for_cases(testrail_client, mocked_response):
    expected_result = Result(status_id=1, comment='Success', case_id=1)
    mocked_response(data_json=[expected_result.to_json()])

    api_results = testrail_client.results.add_results_for_cases(run_id=1, results=[expected_result])

    assert api_results[0] == expected_result
Esempio n. 3
0
def test_add_result(testrail_client, mocked_response):
    expected_result = Result(status_id=1, comment='Success')
    mocked_response(data_json=expected_result.to_json())

    api_result = testrail_client.results.add_result(test_id=1, result=expected_result)

    assert api_result == expected_result
Esempio n. 4
0
 def get_results_for_run(
     self,
     run_id: ModelID,
     filters: typing.Optional[CreatedFilters] = None,
 ) -> typing.List[Result]:
     """http://docs.gurock.com/testrail-api2/reference-results#get_results_for_run"""
     params: JsonData = {}
     if filters is not None:
         params = {
             'created_after':
             filters.get('created_after'),
             'created_before':
             filters.get('created_before'),
             'created_by':
             convert_list_to_filter(values_list=filters.get('created_by')),
             'limit':
             filters.get('limit'),
             'offset':
             filters.get('offset'),
             'status_id':
             convert_list_to_filter(values_list=filters.get('status_ids')),
         }
     results_data = self._request(f'get_results_for_run/{run_id}',
                                  params=params)
     return [Result.from_json(result_data) for result_data in results_data]
Esempio n. 5
0
 def add_results(self, run_id: ModelID,
                 results: typing.List[Result]) -> typing.List[Result]:
     """http://docs.gurock.com/testrail-api2/reference-results#add_results"""
     new_results_data = {
         'results':
         [result.to_json(include_none=False) for result in results],
     }
     results_data = self._request(
         f'add_results/{run_id}',
         method='POST',
         data=new_results_data,
     )
     return [
         Result.from_json(data_json=result_data)
         for result_data in results_data
     ]
Esempio n. 6
0
 def get_results(
     self,
     test_id: ModelID,
     limit: typing.Optional[int] = None,
     offset: typing.Optional[int] = None,
     status_ids: typing.Optional[typing.List[int]] = None,
 ) -> typing.List[Result]:
     """http://docs.gurock.com/testrail-api2/reference-results#get_results"""
     status = ','.join(
         str(status)
         for status in status_ids) if status_ids is not None else ''
     filters = {
         'limit': limit,
         'offset': offset,
         'status_id': status,
     }
     results_data = self._request(f'get_results/{test_id}', params=filters)
     return [Result.from_json(result_data) for result_data in results_data]
Esempio n. 7
0
def test_result_from_json(result_data):
    result = Result.from_json(data_json=result_data)

    assert result.assignedto_id == 1
    assert result.attachment_ids is None
    assert result.comment == 'This test failed: ..'
    assert result.created_by == 1
    assert result.created_on == 1393851801
    assert result.defects == 'TR-1'
    assert result.elapsed == '5m'
    assert result.id == 1
    assert result.status_id == 5
    assert result.test_id == 1
    assert result.version == '1.0RC1'
    assert result.custom == {
        'custom_step_results': [
            {
                'step1': 'pass',
            },
            {
                'step2': 'fail',
            },
        ],
    }
Esempio n. 8
0
def result(result_data):
    return Result.from_json(data_json=result_data)
Esempio n. 9
0
def test_result_to_json(result_data):
    result = Result.from_json(data_json=result_data)

    assert result.to_json() == result_data