This repository was archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
#66: Corrected listing method for local operations #67
Merged
umitbuyuksahin
merged 13 commits into
main
from
bug/#66-correct-listing-method-for-local-operations
May 18, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ff2f04
Updated listing method
umitbuyuksahin 51dd04c
Updated changelog
umitbuyuksahin efb04b4
Visited subfolders recursively
umitbuyuksahin 09ee42d
Fixed error in tests
umitbuyuksahin 694b7bb
Update listing current path
umitbuyuksahin 83812e2
Corrected path for localfs
umitbuyuksahin 21be027
Fix checking error
umitbuyuksahin e17a328
Update exasol_bucketfs_utils_python/localfs_mock_bucketfs_location.py
umitbuyuksahin 60cd930
Updated tests
umitbuyuksahin f570cf6
Raised file not found exception
umitbuyuksahin 9e990d4
Added tests for file not found error
umitbuyuksahin 6b5fe31
Fix deletion test
umitbuyuksahin a2b3cc0
Seperated list files tests
umitbuyuksahin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import pytest | ||
| from exasol_bucketfs_utils_python import upload | ||
| from exasol_bucketfs_utils_python.bucket_config import BucketConfig | ||
| from exasol_bucketfs_utils_python.bucketfs_config import BucketFSConfig | ||
| from exasol_bucketfs_utils_python.bucketfs_connection_config import \ | ||
| BucketFSConnectionConfig | ||
| from tests.test_load_fs_file_from_udf import delete_testfile_from_bucketfs | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def prepare_bucket(): | ||
| connection_config = BucketFSConnectionConfig( | ||
| host="localhost", port=6666, user="w", pwd="write", is_https=False) | ||
| bucketfs_config = BucketFSConfig( | ||
| connection_config=connection_config, bucketfs_name="bfsdefault") | ||
| bucket_config = BucketConfig( | ||
| bucket_name="default", bucketfs_config=bucketfs_config) | ||
| test_string = "test_string" | ||
|
|
||
| path_list = ["path/in/bucket/file.txt", "path/file2.txt"] | ||
| try: | ||
| for path_in_bucket in path_list: | ||
| upload.upload_string_to_bucketfs( | ||
| bucket_config=bucket_config, | ||
| bucket_file_path=path_in_bucket, | ||
| string=test_string) | ||
| yield bucket_config | ||
| finally: | ||
| for path_in_bucket in path_list: | ||
| delete_testfile_from_bucketfs( | ||
| file_path=path_in_bucket, | ||
| bucket_config=bucket_config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,34 @@ | ||
| from exasol_bucketfs_utils_python import upload, list_files | ||
| from exasol_bucketfs_utils_python.bucket_config import BucketConfig | ||
| from exasol_bucketfs_utils_python.bucketfs_config import BucketFSConfig | ||
| from exasol_bucketfs_utils_python.bucketfs_connection_config import BucketFSConnectionConfig | ||
| from tests.test_load_fs_file_from_udf import delete_testfile_from_bucketfs | ||
| import unittest | ||
| import pytest | ||
| from exasol_bucketfs_utils_python import list_files | ||
|
|
||
|
|
||
| def test_list_files(): | ||
| connection_config = BucketFSConnectionConfig( | ||
| host="localhost", port=6666, user="w", pwd="write", is_https=False) | ||
| bucketfs_config = BucketFSConfig( | ||
| connection_config=connection_config, bucketfs_name="bfsdefault") | ||
| bucket_config = BucketConfig( | ||
| bucket_name="default", bucketfs_config=bucketfs_config) | ||
| test_string = "test_string" | ||
| @pytest.mark.parametrize( | ||
| "bucket_path,expected_list", | ||
| [ | ||
| ("path", ["in/bucket/file.txt", "file2.txt"]), | ||
| ("path/", ["in/bucket/file.txt", "file2.txt"]), | ||
| ("path/in", ["bucket/file.txt"]), | ||
| ("path/in/", ["bucket/file.txt"]), | ||
| ("path/in/bucket", ["file.txt"]), | ||
| ("path/in/bucket/", ["file.txt"]), | ||
| ("path/in/bucket/file.txt", []) | ||
| ] | ||
| ) | ||
| def test_list_files(bucket_path, expected_list, prepare_bucket): | ||
| bucket_config = prepare_bucket | ||
| assert set(expected_list) == set(list_files.list_files_in_bucketfs( | ||
| bucket_config, bucket_path)) | ||
|
|
||
| path_list = ["path/in/bucket/file.txt", "path/file2.txt"] | ||
| try: | ||
| for path_in_bucket in path_list: | ||
| upload.upload_string_to_bucketfs( | ||
| bucket_config=bucket_config, | ||
| bucket_file_path=path_in_bucket, | ||
| string=test_string) | ||
|
|
||
| bucket_file_path_map = { | ||
| "path": ["in/bucket/file.txt", "file2.txt"], | ||
| "path/": ["in/bucket/file.txt", "file2.txt"], | ||
| "path/in": ["bucket/file.txt"], | ||
| "path/in/": ["bucket/file.txt"], | ||
| "path/in/bucket": ["file.txt"], | ||
| "path/in/bucket/": ["file.txt"], | ||
| "path/in/bucket/file.txt": ["."] | ||
| } | ||
| for bucket_path, expected in bucket_file_path_map.items(): | ||
| assert expected == list_files.list_files_in_bucketfs( | ||
| bucket_config, bucket_path) | ||
| finally: | ||
| for path_in_bucket in path_list: | ||
| delete_testfile_from_bucketfs( | ||
| file_path=path_in_bucket, | ||
| bucket_config=bucket_config) | ||
| def test_list_files_of_current_directory(prepare_bucket): | ||
| bucket_config = prepare_bucket | ||
| assert {"path/in/bucket/file.txt", "path/file2.txt"}.issubset( | ||
umitbuyuksahin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| set(list_files.list_files_in_bucketfs(bucket_config, "."))) | ||
|
|
||
|
|
||
| def test_file_not_found_error(prepare_bucket): | ||
| bucket_config = prepare_bucket | ||
| bucket_path = "not_existing_path" | ||
| with pytest.raises(FileNotFoundError): | ||
| list_files.list_files_in_bucketfs(bucket_config, bucket_path) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.