From e299f38baab168d10c313ac05f3e3de9e51948dc Mon Sep 17 00:00:00 2001 From: Christoph Kuhnke Date: Mon, 21 Oct 2024 12:56:33 +0200 Subject: [PATCH] #178 improved MockQueryHandlerRunner (#201) Renamed * testing.mock_query_handler_runner to query_handler.python_query_handler_runner * method PythonQueryHandlerRunner.execute_query() to execute_queries() * mock_query_result to python_query_result * Fixed making methods private and made remaining methods private, too * Included type of result in exception during method PythonQueryHandlerRunner.run() Co-authored-by: Torsten Kilias --- doc/changes/changes_0.1.0.md | 4 ++ .../python_query_handler_runner.py} | 42 ++++++++-------- ...query_result.py => python_query_result.py} | 2 +- .../testing/__init__.py | 0 .../test_query_handler_interface.py | 4 +- ...py => test_python_query_handler_runner.py} | 50 +++++++++---------- ..._result.py => test_python_query_result.py} | 30 +++++------ .../test_json_udf_query_handler.py | 4 +- .../test_json_udf_query_handler_factory.py | 4 +- 9 files changed, 72 insertions(+), 68 deletions(-) rename exasol_advanced_analytics_framework/{testing/mock_query_handler_runner.py => query_handler/python_query_handler_runner.py} (78%) rename exasol_advanced_analytics_framework/query_result/{mock_query_result.py => python_query_result.py} (98%) delete mode 100644 exasol_advanced_analytics_framework/testing/__init__.py rename tests/unit_tests/query_handler_runner/{test_mock_query_handler_runner.py => test_python_query_handler_runner.py} (95%) rename tests/unit_tests/query_result/{test_mock_query_result.py => test_python_query_result.py} (74%) diff --git a/doc/changes/changes_0.1.0.md b/doc/changes/changes_0.1.0.md index 90664173..2bdcba1c 100644 --- a/doc/changes/changes_0.1.0.md +++ b/doc/changes/changes_0.1.0.md @@ -52,6 +52,10 @@ Code name: * #176: Updated usage of `exasol-bucketfs` to new API * #185: Removed directory and script for building SLC AAF * #191: Renamed UDF json element "parameters" to "parameter" +* #178: Fixed names of mock objects: + * Renamed `testing.mock_query_handler_runner.MockQueryHandlerRunner` to `query_handler.python_query_handler_runner.PythonQueryHandlerRunner` + * Renamed method `PythonQueryHandlerRunner.execute_query()` to `execute_queries()` + * Renamed `mock_query_result.MockQueryResult` to `python_query_result.PythonQueryResult` ### Documentation diff --git a/exasol_advanced_analytics_framework/testing/mock_query_handler_runner.py b/exasol_advanced_analytics_framework/query_handler/python_query_handler_runner.py similarity index 78% rename from exasol_advanced_analytics_framework/testing/mock_query_handler_runner.py rename to exasol_advanced_analytics_framework/query_handler/python_query_handler_runner.py index 363d7b2e..480dd681 100644 --- a/exasol_advanced_analytics_framework/testing/mock_query_handler_runner.py +++ b/exasol_advanced_analytics_framework/query_handler/python_query_handler_runner.py @@ -13,7 +13,7 @@ from exasol_advanced_analytics_framework.query_handler.query.select_query import SelectQueryWithColumnDefinition from exasol_advanced_analytics_framework.query_handler.query_handler import QueryHandler from exasol_advanced_analytics_framework.query_handler.result import Continue, Finish -from exasol_advanced_analytics_framework.query_result.mock_query_result import MockQueryResult +from exasol_advanced_analytics_framework.query_result.python_query_result import PythonQueryResult from exasol_advanced_analytics_framework.udf_framework.query_handler_runner_state import QueryHandlerRunnerState LOGGER = logging.getLogger(__file__) @@ -22,7 +22,7 @@ ParameterType = TypeVar("ParameterType") -class MockQueryHandlerRunner(Generic[ParameterType, ResultType]): +class PythonQueryHandlerRunner(Generic[ParameterType, ResultType]): def __init__(self, sql_executor: SQLExecutor, @@ -43,28 +43,28 @@ def run(self) -> ResultType: try: result = self._state.query_handler.start() while isinstance(result, Continue): - result = self.handle_continue(result) + result = self._handle_continue(result) if isinstance(result, Finish): - self.handle_finish() + self._handle_finish() return result.result else: - raise RuntimeError("Unknown Result") + raise RuntimeError(f"Unsupported result type {type(result)}") except Exception as e: try: - self.handle_finish() + self._handle_finish() except Exception as e1: LOGGER.exception("Catched exeception during cleanup after an exception.") raise RuntimeError(f"Execution of query handler {self._state.query_handler} failed.") from e - def handle_continue(self, result: Continue) -> Union[Continue, Finish[ResultType]]: - self.release_and_create_query_handler_context_of_input_query() - self.cleanup_query_handler_context() - self.execute_query(result.query_list) - input_query_result = self.run_input_query(result) + def _handle_continue(self, result: Continue) -> Union[Continue, Finish[ResultType]]: + self._release_and_create_query_handler_context_of_input_query() + self._cleanup_query_handler_context() + self._execute_queries(result.query_list) + input_query_result = self._run_input_query(result) result = self._state.query_handler.handle_query_result(input_query_result) return result - def run_input_query(self, result: Continue) -> MockQueryResult: + def _run_input_query(self, result: Continue) -> PythonQueryResult: input_query_view, input_query = self._wrap_return_query(result.input_query) self._sql_executor.execute(input_query_view) input_query_result_set = self._sql_executor.execute(input_query) @@ -72,26 +72,26 @@ def run_input_query(self, result: Continue) -> MockQueryResult: raise RuntimeError(f"Specified columns {result.input_query.output_columns} of the input query " f"are not equal to the actual received columns {input_query_result_set.columns()}") input_query_result_table = input_query_result_set.fetchall() - input_query_result = MockQueryResult(data=input_query_result_table, + input_query_result = PythonQueryResult(data=input_query_result_table, columns=result.input_query.output_columns) return input_query_result - def handle_finish(self): + def _handle_finish(self): if self._state.input_query_query_handler_context is not None: self._state.input_query_query_handler_context.release() self._state.top_level_query_handler_context.release() - self.cleanup_query_handler_context() + self._cleanup_query_handler_context() - def cleanup_query_handler_context(self): + def _cleanup_query_handler_context(self): cleanup_query_list = \ self._state.top_level_query_handler_context.cleanup_released_object_proxies() - self.execute_query(cleanup_query_list) + self._execute_queries(cleanup_query_list) - def execute_query(self, queries: List[Query]): + def _execute_queries(self, queries: List[Query]): for query in queries: self._sql_executor.execute(query.query_string) - def release_and_create_query_handler_context_of_input_query(self): + def _release_and_create_query_handler_context_of_input_query(self): if self._state.input_query_query_handler_context is not None: self._state.input_query_query_handler_context.release() self._state.input_query_query_handler_context = \ @@ -101,7 +101,7 @@ def _wrap_return_query(self, input_query: SelectQueryWithColumnDefinition) -> Tu temporary_view_name = self._state.input_query_query_handler_context.get_temporary_view_name() input_query_create_view_string = cleandoc( f""" -CREATE OR REPLACE VIEW {temporary_view_name.fully_qualified} AS +CREATE OR REPLACE VIEW {temporary_view_name.fully_qualified} AS {input_query.query_string}; """) full_qualified_columns = [col.name.fully_qualified @@ -109,7 +109,7 @@ def _wrap_return_query(self, input_query: SelectQueryWithColumnDefinition) -> Tu columns_str = ",\n".join(full_qualified_columns) input_query_string = cleandoc( f""" -SELECT +SELECT {textwrap.indent(columns_str, " " * 4)} FROM {temporary_view_name.fully_qualified}; """) diff --git a/exasol_advanced_analytics_framework/query_result/mock_query_result.py b/exasol_advanced_analytics_framework/query_result/python_query_result.py similarity index 98% rename from exasol_advanced_analytics_framework/query_result/mock_query_result.py rename to exasol_advanced_analytics_framework/query_result/python_query_result.py index 3b666948..d8586757 100644 --- a/exasol_advanced_analytics_framework/query_result/mock_query_result.py +++ b/exasol_advanced_analytics_framework/query_result/python_query_result.py @@ -6,7 +6,7 @@ from exasol_advanced_analytics_framework.query_result.query_result import QueryResult, Row -class MockQueryResult(QueryResult): +class PythonQueryResult(QueryResult): def __getattr__(self, name: str) -> Any: return self[name] diff --git a/exasol_advanced_analytics_framework/testing/__init__.py b/exasol_advanced_analytics_framework/testing/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/unit_tests/query_handler/test_query_handler_interface.py b/tests/unit_tests/query_handler/test_query_handler_interface.py index 874b94a9..409a0e7e 100644 --- a/tests/unit_tests/query_handler/test_query_handler_interface.py +++ b/tests/unit_tests/query_handler/test_query_handler_interface.py @@ -12,7 +12,7 @@ from exasol_advanced_analytics_framework.query_handler.query_handler import QueryHandler from exasol_advanced_analytics_framework.query_handler.result import Continue, \ Finish -from exasol_advanced_analytics_framework.query_result.mock_query_result import MockQueryResult +from exasol_advanced_analytics_framework.query_result.python_query_result import PythonQueryResult from exasol_advanced_analytics_framework.query_result.query_result import QueryResult @@ -36,7 +36,7 @@ def test(): handler = TestQueryHandler({"a": 2}, query_handler_context) result = handler.start() if isinstance(result, Continue): - query_result = MockQueryResult([(2,)], result.input_query.output_columns) + query_result = PythonQueryResult([(2,)], result.input_query.output_columns) actual_result = handler.handle_query_result(query_result).result assert actual_result == 2 else: diff --git a/tests/unit_tests/query_handler_runner/test_mock_query_handler_runner.py b/tests/unit_tests/query_handler_runner/test_python_query_handler_runner.py similarity index 95% rename from tests/unit_tests/query_handler_runner/test_mock_query_handler_runner.py rename to tests/unit_tests/query_handler_runner/test_python_query_handler_runner.py index dde1b85b..6dcd99f0 100644 --- a/tests/unit_tests/query_handler_runner/test_mock_query_handler_runner.py +++ b/tests/unit_tests/query_handler_runner/test_python_query_handler_runner.py @@ -19,7 +19,7 @@ from exasol_advanced_analytics_framework.query_handler.query_handler import QueryHandler from exasol_advanced_analytics_framework.query_handler.result import Continue, Finish from exasol_advanced_analytics_framework.query_result.query_result import QueryResult -from exasol_advanced_analytics_framework.testing.mock_query_handler_runner import MockQueryHandlerRunner +from exasol_advanced_analytics_framework.query_handler.python_query_handler_runner import PythonQueryHandlerRunner EXPECTED_EXCEPTION = "ExpectedException" @@ -71,7 +71,7 @@ def test_start_finish(top_level_query_handler_context): """ sql_executor = MockSQLExecutor(result_sets=[]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -103,7 +103,7 @@ def test_start_finish_cleanup_queries(temporary_schema_name, top_level_query_han """ sql_executor = MockSQLExecutor(result_sets=[MockResultSet()]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -135,7 +135,7 @@ def test_start_error_cleanup_queries(temporary_schema_name, top_level_query_hand """ sql_executor = MockSQLExecutor(result_sets=[MockResultSet()]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -188,7 +188,7 @@ def test_continue_finish(temporary_schema_name, top_level_query_handler_context) drop_input_query_view_result_set ]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -199,13 +199,13 @@ def test_continue_finish(temporary_schema_name, top_level_query_handler_context) sql_executor.queries == [ cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS SELECT 1 as "a"; """ ), cleandoc( f""" - SELECT\x20 + SELECT "a" FROM "{temporary_schema_name}"."temp_db_object_2_1"; """), @@ -246,7 +246,7 @@ def test_continue_wrong_columns(temporary_schema_name, top_level_query_handler_c drop_input_query_view_result_set ]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -302,7 +302,7 @@ def test_continue_query_list(temporary_schema_name, top_level_query_handler_cont drop_input_query_view_result_set ]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -314,12 +314,12 @@ def test_continue_query_list(temporary_schema_name, top_level_query_handler_cont f"""SELECT 1""", cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS SELECT 1 as "a"; """), cleandoc( f""" - SELECT\x20 + SELECT "a" FROM "{temporary_schema_name}"."temp_db_object_2_1"; """), @@ -367,7 +367,7 @@ def test_continue_error_cleanup_queries(temporary_schema_name, top_level_query_h drop_input_query_view_result_set ]) test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -378,12 +378,12 @@ def test_continue_error_cleanup_queries(temporary_schema_name, top_level_query_h assert sql_executor.queries == [ cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS SELECT 1 as "a"; """), cleandoc( f""" - SELECT\x20 + SELECT "a" FROM "{temporary_schema_name}"."temp_db_object_2_1"; """), @@ -453,7 +453,7 @@ def test_continue_continue_finish(temporary_schema_name, top_level_query_handler ]) temporary_schema_name = "temp_schema_name" test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -464,24 +464,24 @@ def test_continue_continue_finish(temporary_schema_name, top_level_query_handler sql_executor.queries == [ cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_2_1" AS SELECT 1 as "a"; """), cleandoc( f""" - SELECT\x20 + SELECT "a" FROM "{temporary_schema_name}"."temp_db_object_2_1"; """), f"""DROP VIEW IF EXISTS "{temporary_schema_name}"."temp_db_object_2_1";""", cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_4_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_4_1" AS SELECT 1 as "b"; """), cleandoc( f""" - SELECT\x20 + SELECT "b" FROM "{temporary_schema_name}"."temp_db_object_4_1"; """), @@ -552,7 +552,7 @@ def test_continue_cleanup_continue_finish(temporary_schema_name, top_level_query ]) temporary_schema_name = "temp_schema_name" test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, @@ -563,12 +563,12 @@ def test_continue_cleanup_continue_finish(temporary_schema_name, top_level_query sql_executor.queries == [ cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_4_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_4_1" AS SELECT 1 as "a"; """), cleandoc( f""" - SELECT\x20 + SELECT "a" FROM "{temporary_schema_name}"."temp_db_object_4_1"; """), @@ -576,12 +576,12 @@ def test_continue_cleanup_continue_finish(temporary_schema_name, top_level_query f"""DROP TABLE IF EXISTS "{temporary_schema_name}"."temp_db_object_2_1";""", cleandoc( f""" - CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_6_1" AS\x20 + CREATE OR REPLACE VIEW "{temporary_schema_name}"."temp_db_object_6_1" AS SELECT 1 as "b"; """), cleandoc( f""" - SELECT\x20 + SELECT "b" FROM "{temporary_schema_name}"."temp_db_object_6_1"; """), @@ -607,7 +607,7 @@ def test_fail_in_cleanup(temporary_schema_name, top_level_query_handler_context) sql_executor = MockSQLExecutor() temporary_schema_name = "temp_schema_name" test_input = TestInput() - query_handler_runner = MockQueryHandlerRunner[TestInput, TestOutput]( + query_handler_runner = PythonQueryHandlerRunner[TestInput, TestOutput]( sql_executor=sql_executor, top_level_query_handler_context=top_level_query_handler_context, parameter=test_input, diff --git a/tests/unit_tests/query_result/test_mock_query_result.py b/tests/unit_tests/query_result/test_python_query_result.py similarity index 74% rename from tests/unit_tests/query_result/test_mock_query_result.py rename to tests/unit_tests/query_result/test_python_query_result.py index 95cbd5a7..11b74b31 100644 --- a/tests/unit_tests/query_result/test_mock_query_result.py +++ b/tests/unit_tests/query_result/test_python_query_result.py @@ -2,7 +2,7 @@ from exasol_data_science_utils_python.schema.column_name import ColumnName from exasol_data_science_utils_python.schema.column_type import ColumnType -from exasol_advanced_analytics_framework.query_result.mock_query_result import MockQueryResult +from exasol_advanced_analytics_framework.query_result.python_query_result import PythonQueryResult DATA_SIZE = 100 FETCH_SIZE = 10 @@ -15,20 +15,20 @@ def test_fetch_as_dataframe_column_names(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) df = context.fetch_as_dataframe(num_rows=1) assert list(df.columns) == [column.name.name for column in INPUT_COLUMNS] def test_fetch_as_dataframe_first_batch(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) df = context.fetch_as_dataframe(num_rows=10) dataframe_list_of_tuples = list(df.itertuples(index=False, name=None)) assert dataframe_list_of_tuples == INPUT_DATA[:10] def test_fetch_as_dataframe_second_batch(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) df = context.fetch_as_dataframe(num_rows=10) df = context.fetch_as_dataframe(num_rows=20) dataframe_list_of_tuples = list(df.itertuples(index=False, name=None)) @@ -36,7 +36,7 @@ def test_fetch_as_dataframe_second_batch(): def test_fetch_as_dataframe_after_last_batch(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) result = [] while True: df = context.fetch_as_dataframe(num_rows=9) @@ -47,37 +47,37 @@ def test_fetch_as_dataframe_after_last_batch(): def test_fetch_as_dataframe_all_rows(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) df = context.fetch_as_dataframe(num_rows="all") dataframe_list_of_tuples = list(df.itertuples(index=False, name=None)) assert dataframe_list_of_tuples == INPUT_DATA def test_fetch_as_dataframe_start_col(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) df = context.fetch_as_dataframe(num_rows=1, start_col=1) dataframe_list_of_tuples = list(df.itertuples(index=False, name=None)) assert dataframe_list_of_tuples[0] == INPUT_DATA[0][1:] def test_rowcount(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) assert context.rowcount() == len(INPUT_DATA) def test_column_names(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) column_names = [column.name.name for column in INPUT_COLUMNS] assert context.column_names() == column_names def test_columns(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) assert context.columns() == INPUT_COLUMNS def test_column_get_attr(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) t1 = context.t1 t2 = context.t2 t3 = context.t3 @@ -85,7 +85,7 @@ def test_column_get_attr(): def test_column_get_item(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) t1 = context["t1"] t2 = context["t2"] t3 = context["t3"] @@ -93,7 +93,7 @@ def test_column_get_item(): def test_column_next_get_item(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) result = [] while True: t1 = context["t1"] @@ -106,7 +106,7 @@ def test_column_next_get_item(): def test_column_next_get_attr(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) result = [] while True: t1 = context.t1 @@ -119,7 +119,7 @@ def test_column_next_get_attr(): def test_column_iterator(): - context = MockQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) + context = PythonQueryResult(data=INPUT_DATA, columns=INPUT_COLUMNS) result = [] for row in context: result.append((row[0], row[1], row[2])) diff --git a/tests/unit_tests/udf_framework/test_json_udf_query_handler.py b/tests/unit_tests/udf_framework/test_json_udf_query_handler.py index 8ae06ba5..1db33709 100644 --- a/tests/unit_tests/udf_framework/test_json_udf_query_handler.py +++ b/tests/unit_tests/udf_framework/test_json_udf_query_handler.py @@ -12,7 +12,7 @@ ScopeQueryHandlerContext from exasol_advanced_analytics_framework.query_handler.json_udf_query_handler import JSONQueryHandler, JSONType from exasol_advanced_analytics_framework.query_handler.result import Continue, Finish -from exasol_advanced_analytics_framework.query_result.mock_query_result import MockQueryResult +from exasol_advanced_analytics_framework.query_result.python_query_result import PythonQueryResult from exasol_advanced_analytics_framework.query_result.query_result import QueryResult from exasol_advanced_analytics_framework.udf_framework.json_udf_query_handler_factory import JsonUDFQueryHandler @@ -102,7 +102,7 @@ def test_handle_query_result_check_query_result(top_level_query_handler_context) wrapped_json_query_handler_class=HandleQueryResultCheckQueryResultTestJSONQueryHandler ) result = query_handler.handle_query_result( - MockQueryResult(data=[(1,)], + PythonQueryResult(data=[(1,)], columns=[Column(ColumnName("a"), ColumnType("INTEGER"))])) assert isinstance(result, Finish) and result.result == '{"a": 1}' diff --git a/tests/unit_tests/udf_framework/test_json_udf_query_handler_factory.py b/tests/unit_tests/udf_framework/test_json_udf_query_handler_factory.py index 8cb90f25..ded827f2 100644 --- a/tests/unit_tests/udf_framework/test_json_udf_query_handler_factory.py +++ b/tests/unit_tests/udf_framework/test_json_udf_query_handler_factory.py @@ -10,7 +10,7 @@ ScopeQueryHandlerContext from exasol_advanced_analytics_framework.query_handler.json_udf_query_handler import JSONQueryHandler, JSONType from exasol_advanced_analytics_framework.query_handler.result import Continue, Finish -from exasol_advanced_analytics_framework.query_result.mock_query_result import MockQueryResult +from exasol_advanced_analytics_framework.query_result.python_query_result import PythonQueryResult from exasol_advanced_analytics_framework.query_result.query_result import QueryResult from exasol_advanced_analytics_framework.udf_framework.json_udf_query_handler_factory import JsonUDFQueryHandlerFactory from exasol_advanced_analytics_framework.udf_framework.udf_query_handler import UDFQueryHandler @@ -41,7 +41,7 @@ def test(top_level_query_handler_context): query_handler = TestJsonUDFQueryHandlerFactory().create(json_str, top_level_query_handler_context) start_result = query_handler.start() handle_query_result = query_handler.handle_query_result( - MockQueryResult(data=[(1,)], + PythonQueryResult(data=[(1,)], columns=[Column(ColumnName("a"), ColumnType("INTEGER"))]) )