Skip to content

Commit 1d84a4d

Browse files
committed
#224: Replaced references to old BucketFS API with new API
1 parent 0e2a995 commit 1d84a4d

File tree

5 files changed

+40
-49
lines changed

5 files changed

+40
-49
lines changed

doc/changes/unreleased.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Unreleased
2+
3+
## Refactorings
4+
5+
* #224: Replaced references to old BucketFS API with new API

tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/state_test_setup.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from typing import List, Union
33
from unittest.mock import MagicMock, Mock, create_autospec
44

5-
from exasol_bucketfs_utils_python.abstract_bucketfs_location import (
6-
AbstractBucketFSLocation,
7-
)
5+
import exasol.bucketfs as bfs
86

97
from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext
108
from exasol.analytics.query_handler.graph.stage.sql.execution.input import (
@@ -40,7 +38,7 @@
4038
MockObjectProxyReferenceCountingBagFactory = Union[
4139
ObjectProxyReferenceCountingBag, Mock
4240
]
43-
MockBucketFSLocation = Union[AbstractBucketFSLocation, MagicMock]
41+
MockBucketFSLocation = Union[bfs.path.PathLike, MagicMock]
4442

4543

4644
@dataclasses.dataclass
@@ -111,7 +109,7 @@ def create_execution_query_handler_state_setup(
111109
SQLStageInputOutput
112110
)
113111
mock_result_bucketfs_location: MockBucketFSLocation = create_autospec(
114-
AbstractBucketFSLocation
112+
bfs.path.PathLike
115113
)
116114
stage_result_bucketfs_locations = [
117115
stage_setup.result_bucketfs_location for stage_setup in stage_setups
@@ -176,7 +174,7 @@ def create_mocks_for_stage(
176174
query_handler: MockSQLStageQueryHandler = create_autospec(QueryHandler)
177175
sql_stage.create_query_handler.return_value = query_handler
178176
mock_result_bucketfs_location: MockBucketFSLocation = create_autospec(
179-
AbstractBucketFSLocation
177+
bfs.path.PathLike
180178
)
181179
return StageSetup(
182180
index=stage_index,

tests/unit_tests/sql_stage_graph/stage_graph_execution_query_handler/test_query_handler_integration.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from unittest.mock import Mock
77

88
import pytest
9-
from exasol_bucketfs_utils_python.localfs_mock_bucketfs_location import (
10-
LocalFSMockBucketFSLocation,
11-
)
9+
import exasol.bucketfs as bfs
1210

1311
from exasol.analytics.query_handler.context.scope import ScopeQueryHandlerContext
1412
from exasol.analytics.query_handler.context.top_level_query_handler_context import (
@@ -224,14 +222,12 @@ def create_test_setup(
224222
sql_stage_graph: SQLStageGraph,
225223
stages: List[TestSQLStage],
226224
context: TopLevelQueryHandlerContext,
227-
local_fs_mock_bucket_fs_tmp_path: PurePosixPath,
225+
bucketfs_location: bfs.path.PathLike,
228226
) -> TestSetup:
229227
stage_input_output = create_input()
230228
parameter = SQLStageGraphExecutionInput(
231229
sql_stage_graph=sql_stage_graph,
232-
result_bucketfs_location=LocalFSMockBucketFSLocation(
233-
local_fs_mock_bucket_fs_tmp_path
234-
),
230+
result_bucketfs_location=bucketfs_location,
235231
input=stage_input_output,
236232
)
237233
child_query_handler_context = context.get_child_query_handler_context()
@@ -247,7 +243,8 @@ def create_test_setup(
247243

248244

249245
def test_start_with_single_stage_with_start_only_forward_query_handler(
250-
top_level_query_handler_context_mock, tmp_path
246+
top_level_query_handler_context_mock,
247+
mocked_temporary_bucketfs_location,
251248
):
252249
"""
253250
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
@@ -270,7 +267,7 @@ def arrange() -> TestSetup:
270267
sql_stage_graph=sql_stage_graph,
271268
stages=[stage1],
272269
context=top_level_query_handler_context_mock,
273-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
270+
bucketfs_location=mocked_temporary_bucketfs_location,
274271
)
275272
return test_setup
276273

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

298295

299296
def test_start_with_two_stages_with_start_only_forward_query_handler(
300-
top_level_query_handler_context_mock, tmp_path
297+
top_level_query_handler_context_mock,
298+
mocked_temporary_bucketfs_location,
301299
):
302300
"""
303301
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
@@ -326,7 +324,7 @@ def arrange() -> TestSetup:
326324
sql_stage_graph=sql_stage_graph,
327325
stages=[stage1, stage2],
328326
context=top_level_query_handler_context_mock,
329-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
327+
bucketfs_location=mocked_temporary_bucketfs_location,
330328
)
331329
return test_setup
332330

@@ -361,7 +359,8 @@ def not_raises(exception):
361359

362360

363361
def test_start_with_single_stage_with_start_only_create_new_output_query_handler(
364-
top_level_query_handler_context_mock, tmp_path
362+
top_level_query_handler_context_mock,
363+
mocked_temporary_bucketfs_location,
365364
):
366365
"""
367366
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
@@ -386,7 +385,7 @@ def arrange() -> TestSetup:
386385
sql_stage_graph=sql_stage_graph,
387386
stages=[stage1],
388387
context=top_level_query_handler_context_mock,
389-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
388+
bucketfs_location=mocked_temporary_bucketfs_location,
390389
)
391390
return test_setup
392391

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

427426

428427
def test_start_with_two_stages_with_start_only_create_new_output_query_handler(
429-
top_level_query_handler_context_mock, tmp_path
428+
top_level_query_handler_context_mock,
429+
mocked_temporary_bucketfs_location,
430430
):
431431
"""
432432
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
@@ -457,7 +457,7 @@ def arrange() -> TestSetup:
457457
sql_stage_graph=sql_stage_graph,
458458
stages=[stage1, stage2],
459459
context=top_level_query_handler_context_mock,
460-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
460+
bucketfs_location=mocked_temporary_bucketfs_location,
461461
)
462462
return test_setup
463463

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

502502

503503
def test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1(
504-
top_level_query_handler_context_mock, tmp_path
504+
top_level_query_handler_context_mock,
505+
mocked_temporary_bucketfs_location,
505506
):
506507
"""
507508
This test runs an integration test for the start method of a SQLStageGraphExecutionQueryHandler
@@ -523,7 +524,7 @@ def arrange() -> TestSetup:
523524
sql_stage_graph=sql_stage_graph,
524525
stages=[stage1],
525526
context=top_level_query_handler_context_mock,
526-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
527+
bucketfs_location=mocked_temporary_bucketfs_location,
527528
)
528529
return test_setup
529530

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

550551

551552
def test_handle_query_result_with_single_stage_with_handle_query_result_create_new_output_query_handler_part2(
552-
top_level_query_handler_context_mock, tmp_path
553+
top_level_query_handler_context_mock,
554+
mocked_temporary_bucketfs_location,
553555
):
554556
"""
555557
This test uses test_start_with_single_stage_with_handle_query_result_create_new_output_query_handler_part1
@@ -574,7 +576,7 @@ def arrange() -> Tuple[TestSetup, QueryResult]:
574576
sql_stage_graph=sql_stage_graph,
575577
stages=[stage1],
576578
context=top_level_query_handler_context_mock,
577-
local_fs_mock_bucket_fs_tmp_path=PurePosixPath(tmp_path),
579+
bucketfs_location=mocked_temporary_bucketfs_location,
578580
)
579581
test_setup.query_handler.start()
580582
query_result: QueryResult = Mock()

tests/unit_tests/sql_stage_graph/test_object_proxy_reference_counting_bag_with_query_handler_context_impl.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from pathlib import PurePosixPath
22

33
import pytest
4-
from exasol_bucketfs_utils_python.localfs_mock_bucketfs_location import (
5-
LocalFSMockBucketFSLocation,
6-
)
74

85
from exasol.analytics.query_handler.context.top_level_query_handler_context import (
96
TopLevelQueryHandlerContext,

tests/unit_tests/sql_stage_graph/test_sql_stage_train_query_handler_input.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from unittest.mock import MagicMock, create_autospec
33

44
import pytest
5-
from exasol_bucketfs_utils_python.abstract_bucketfs_location import (
6-
AbstractBucketFSLocation,
7-
)
5+
import exasol.bucketfs as bfs
86

97
from exasol.analytics.query_handler.graph.stage.sql.input_output import (
108
SQLStageInputOutput,
@@ -14,20 +12,20 @@
1412
)
1513

1614

15+
def mock_bfs_location() -> Union[bfs.path.PathLike, MagicMock]:
16+
return create_autospec(bfs.path.PathLike)
17+
18+
1719
def test_empty_stage_inputs():
18-
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
19-
AbstractBucketFSLocation
20-
)
20+
bucketfs_location = mock_bfs_location()
2121
with pytest.raises(AssertionError, match="Empty sql_stage_inputs not allowed."):
2222
SQLStageQueryHandlerInput(
2323
sql_stage_inputs=[], result_bucketfs_location=bucketfs_location
2424
)
2525

2626

2727
def test_non_empty_stage_inputs():
28-
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
29-
AbstractBucketFSLocation
30-
)
28+
bucketfs_location = mock_bfs_location()
3129
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
3230
SQLStageInputOutput
3331
)
@@ -41,9 +39,7 @@ def test_non_empty_stage_inputs():
4139

4240

4341
def test_equality():
44-
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
45-
AbstractBucketFSLocation
46-
)
42+
bucketfs_location = mock_bfs_location()
4743
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
4844
SQLStageInputOutput
4945
)
@@ -57,9 +53,7 @@ def test_equality():
5753

5854

5955
def test_inequality_sql_stage_input():
60-
bucketfs_location: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
61-
AbstractBucketFSLocation
62-
)
56+
bucketfs_location = mock_bfs_location()
6357
sql_stage_input1: Union[SQLStageInputOutput, MagicMock] = create_autospec(
6458
SQLStageInputOutput
6559
)
@@ -76,12 +70,8 @@ def test_inequality_sql_stage_input():
7670

7771

7872
def test_inequality_bucketfs_location():
79-
bucketfs_location1: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
80-
AbstractBucketFSLocation
81-
)
82-
bucketfs_location2: Union[AbstractBucketFSLocation, MagicMock] = create_autospec(
83-
AbstractBucketFSLocation
84-
)
73+
bucketfs_location1 = mock_bfs_location()
74+
bucketfs_location2 = mock_bfs_location()
8575
sql_stage_input: Union[SQLStageInputOutput, MagicMock] = create_autospec(
8676
SQLStageInputOutput
8777
)

0 commit comments

Comments
 (0)