def test_request_reviews_no_host(self, mock_format_response, mock_call_api, mock_check_repo_exists, mock_get_response): """ Tests 'get_reviews' function where: * Self.url == host * Repos exist """ # Set up mock return values and side effects mock_check_repo_exists.return_value = True mock_call_api.return_value = 'mock_review_response' mock_format_response.return_value = 'Successful Call!' service = GerritService() service.host_exists = True # Call function response = service.request_reviews(host=None, repo_name='mock_repo') # Validate function calls and response mock_get_response.assert_not_called() mock_check_repo_exists.assert_called_with('mock_repo', True) changes_url = ('None/changes/?q=project:mock_repo+status:open' '&o=DETAILED_ACCOUNTS' '&o=DETAILED_LABELS') mock_call_api.assert_called_with(url=changes_url, ssl_verify=True) mock_format_response.assert_called_with('mock_review_response', None, None) self.assertEqual('Successful Call!', response)
def test_request_reviews_no_repos(self, mock_format_response, mock_call_api, mock_check_repo_exists, mock_get_response): """ Tests 'get_reviews' function where: * Self.url == host * Repos don't exists """ # Set up mock return values and side effects mock_check_repo_exists.return_value = None mock_call_api.return_value = 'mock_review_response' mock_format_response.return_value = 'Successful Call!' service = GerritService() service.host_exists = True # Call function response = service.request_reviews(host=None, repo_name='mock_repo') # Validate function calls and response mock_get_response.assert_not_called() mock_check_repo_exists.assert_called_with('mock_repo', True) mock_call_api.assert_not_called() mock_format_response.assert_not_called() self.assertEqual(None, response)