Пример #1
0
    def test_query_flow(self, mock_results_response, mock_status_response,
                        mock_query_response, mock_api_client):
        mock_api_client.return_value = None

        query_mock = "27F369FB69B2458D"
        mock_query_response.return_value = SumoLogicMockResponse(
            200, query_mock)

        dir_path = os.path.dirname(os.path.realpath(__file__))
        file_path = os.path.join(dir_path, 'api_response',
                                 'result_by_sid.json')
        results_mock = open(file_path, 'r').read()
        mock_results_response.return_value = SumoLogicMockResponse(
            200, results_mock)

        status_mock = "DONE GATHERING RESULTS"
        mock_status_response.return_value = SumoLogicMockResponse(
            200, status_mock)

        query = "{\"query\": \"(_sourcehost = \\\"sumologic.domain_name.com\\\")\"," \
                "\n\"fromTime\": \"20211007T111938\",\n\"toTime\": \"20211007T113438\"}"
        entry_point = EntryPoint(self.connection(), self.configuration())
        query_response = entry_point.create_query_connection(query)

        assert query_response is not None
        assert query_response['success'] is True
        assert 'search_id' in query_response
        assert query_response['search_id'] == "27F369FB69B2458D"

        search_id = "27F369FB69B2458D"
        status_response = entry_point.create_status_connection(search_id)

        assert status_response is not None
        assert 'status' in status_response
        assert status_response['status'] == 'COMPLETED'
        assert 'progress' in status_response
        assert status_response['progress'] == 100
        assert 'success' in status_response
        assert status_response['success'] is True

        search_id = "27F369FB69B2458D"
        offset = 0
        length = 1
        results_response = entry_point.create_results_connection(
            search_id, offset, length)

        assert 'success' in results_response
        assert results_response['success'] is True
        assert 'data' in results_response
        assert len(results_response['data']) > 0
Пример #2
0
    def test_results_response_empty_list(self, mock_results_response,
                                         mock_api_client):
        mock_api_client.return_value = None
        mocked_return_value = list()

        mock_results_response.return_value = SumoLogicMockResponse(
            200, mocked_return_value)

        search_id = "27F369FB69B2458D"
        offset = 0
        length = 1
        entry_point = EntryPoint(self.connection(), self.configuration())
        results_response = entry_point.create_results_connection(
            search_id, offset, length)

        assert 'success' in results_response
        assert results_response['success'] is True
        assert 'data' in results_response
        assert len(results_response['data']) == 0