Skip to content

Commit

Permalink
#224: Replaced references to old BucketFS API with new API
Browse files Browse the repository at this point in the history
  • Loading branch information
ckunki committed Jan 8, 2025
1 parent 0e2a995 commit 1d84a4d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 49 deletions.
4 changes: 4 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Unreleased

## Refactorings

* #224: Replaced references to old BucketFS API with new API
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from typing import List, Union
from unittest.mock import MagicMock, Mock, create_autospec

from exasol_bucketfs_utils_python.abstract_bucketfs_location import (
AbstractBucketFSLocation,
)
import exasol.bucketfs as bfs

from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext
from exasol.analytics.query_handler.graph.stage.sql.execution.input import (
Expand Down Expand Up @@ -40,7 +38,7 @@
MockObjectProxyReferenceCountingBagFactory = Union[
ObjectProxyReferenceCountingBag, Mock
]
MockBucketFSLocation = Union[AbstractBucketFSLocation, MagicMock]
MockBucketFSLocation = Union[bfs.path.PathLike, MagicMock]


@dataclasses.dataclass
Expand Down Expand Up @@ -111,7 +109,7 @@ def create_execution_query_handler_state_setup(
SQLStageInputOutput
)
mock_result_bucketfs_location: MockBucketFSLocation = create_autospec(
AbstractBucketFSLocation
bfs.path.PathLike
)
stage_result_bucketfs_locations = [
stage_setup.result_bucketfs_location for stage_setup in stage_setups
Expand Down Expand Up @@ -176,7 +174,7 @@ def create_mocks_for_stage(
query_handler: MockSQLStageQueryHandler = create_autospec(QueryHandler)
sql_stage.create_query_handler.return_value = query_handler
mock_result_bucketfs_location: MockBucketFSLocation = create_autospec(
AbstractBucketFSLocation
bfs.path.PathLike
)
return StageSetup(
index=stage_index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from unittest.mock import Mock

import pytest
from exasol_bucketfs_utils_python.localfs_mock_bucketfs_location import (
LocalFSMockBucketFSLocation,
)
import exasol.bucketfs as bfs

from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext
from exasol.analytics.query_handler.context.top_level_query_handler_context import (
Expand Down Expand Up @@ -224,14 +222,12 @@ def create_test_setup(
sql_stage_graph: SQLStageGraph,
stages: List[TestSQLStage],
context: TopLevelQueryHandlerContext,
local_fs_mock_bucket_fs_tmp_path: PurePosixPath,
bucketfs_location: bfs.path.PathLike,
) -> TestSetup:
stage_input_output = create_input()
parameter = SQLStageGraphExecutionInput(
sql_stage_graph=sql_stage_graph,
result_bucketfs_location=LocalFSMockBucketFSLocation(
local_fs_mock_bucket_fs_tmp_path
),
result_bucketfs_location=bucketfs_location,
input=stage_input_output,
)
child_query_handler_context = context.get_child_query_handler_context()
Expand All @@ -247,7 +243,8 @@ def create_test_setup(


def test_start_with_single_stage_with_start_only_forward_query_handler(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
Expand All @@ -270,7 +267,7 @@ def arrange() -> TestSetup:
sql_stage_graph=sql_stage_graph,
stages=[stage1],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
return test_setup

Expand All @@ -297,7 +294,8 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]:


def test_start_with_two_stages_with_start_only_forward_query_handler(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
Expand Down Expand Up @@ -326,7 +324,7 @@ def arrange() -> TestSetup:
sql_stage_graph=sql_stage_graph,
stages=[stage1, stage2],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
return test_setup

Expand Down Expand Up @@ -361,7 +359,8 @@ def not_raises(exception):


def test_start_with_single_stage_with_start_only_create_new_output_query_handler(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
Expand All @@ -386,7 +385,7 @@ def arrange() -> TestSetup:
sql_stage_graph=sql_stage_graph,
stages=[stage1],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
return test_setup

Expand Down Expand Up @@ -426,7 +425,8 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]:


def test_start_with_two_stages_with_start_only_create_new_output_query_handler(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
Expand Down Expand Up @@ -457,7 +457,7 @@ def arrange() -> TestSetup:
sql_stage_graph=sql_stage_graph,
stages=[stage1, stage2],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
return test_setup

Expand Down Expand Up @@ -501,7 +501,8 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]:


def test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
Expand All @@ -523,7 +524,7 @@ def arrange() -> TestSetup:
sql_stage_graph=sql_stage_graph,
stages=[stage1],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
return test_setup

Expand All @@ -549,7 +550,8 @@ def act(test_setup: TestSetup) -> Union[Continue, Finish[SQLStageInputOutput]]:


def test_handle_query_result_with_single_stage_with_handle_query_result_create_new_output_query_handler_part2(
top_level_query_handler_context_mock, tmp_path
top_level_query_handler_context_mock,
mocked_temporary_bucketfs_location,
):
"""
This test uses test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1
Expand All @@ -574,7 +576,7 @@ def arrange() -> Tuple[TestSetup, QueryResult]:
sql_stage_graph=sql_stage_graph,
stages=[stage1],
context=top_level_query_handler_context_mock,
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
bucketfs_location=mocked_temporary_bucketfs_location,
)
test_setup.query_handler.start()
query_result: QueryResult = Mock()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from pathlib import PurePosixPath

import pytest
from exasol_bucketfs_utils_python.localfs_mock_bucketfs_location import (
LocalFSMockBucketFSLocation,
)

from exasol.analytics.query_handler.context.top_level_query_handler_context import (
TopLevelQueryHandlerContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from unittest.mock import MagicMock, create_autospec

import pytest
from exasol_bucketfs_utils_python.abstract_bucketfs_location import (
AbstractBucketFSLocation,
)
import exasol.bucketfs as bfs

from exasol.analytics.query_handler.graph.stage.sql.input_output import (
SQLStageInputOutput,
Expand All @@ -14,20 +12,20 @@
)


def mock_bfs_location() -> Union[bfs.path.PathLike, MagicMock]:
return create_autospec(bfs.path.PathLike)


def test_empty_stage_inputs():
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location = mock_bfs_location()
with pytest.raises(AssertionError, match="Empty sql_stage_inputs not allowed."):
SQLStageQueryHandlerInput(
sql_stage_inputs=[], result_bucketfs_location=bucketfs_location
)


def test_non_empty_stage_inputs():
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location = mock_bfs_location()
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
SQLStageInputOutput
)
Expand All @@ -41,9 +39,7 @@ def test_non_empty_stage_inputs():


def test_equality():
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location = mock_bfs_location()
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
SQLStageInputOutput
)
Expand All @@ -57,9 +53,7 @@ def test_equality():


def test_inequality_sql_stage_input():
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location = mock_bfs_location()
sql_stage_input1: Union[SQLStageInputOutput, MagicMock] = create_autospec(
SQLStageInputOutput
)
Expand All @@ -76,12 +70,8 @@ def test_inequality_sql_stage_input():


def test_inequality_bucketfs_location():
bucketfs_location1: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location2: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
AbstractBucketFSLocation
)
bucketfs_location1 = mock_bfs_location()
bucketfs_location2 = mock_bfs_location()
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
SQLStageInputOutput
)
Expand Down

0 comments on commit 1d84a4d

Please sign in to comment.