Skip to content

Commit 41ed9ee

Browse files
committed
testing for list files with prefix added
1 parent ec3188d commit 41ed9ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/happtiq_commons_google_cloud/tests/happtiq_commons_google_cloud/gcs_service_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,21 @@ def test_upload_file_gzipped(gcs_api_service, monkeypatch):
7474
gcs_api_service.client.bucket().blob.assert_called_once_with(destination)
7575
gcs_api_service.client.bucket().blob(destination).upload_from_filename.assert_called_once_with(file_path, content_type=content_type, timeout=30)
7676
gcs_api_service.client.bucket().blob(destination).content_encoding = "gzip"
77+
78+
def test_list_files_with_prefix(gcs_api_service, monkeypatch):
79+
mock_client = MagicMock()
80+
mock_bucket = MagicMock()
81+
mock_blobs = [MagicMock(name="file1.txt"), MagicMock(name="file2.txt")]
82+
83+
mock_client.bucket.return_value = mock_bucket
84+
mock_bucket.list_blobs.return_value = mock_blobs
85+
monkeypatch.setattr(gcs_api_service, "client", mock_client)
86+
87+
bucket_name = "test-bucket"
88+
prefix = "test-prefix/"
89+
90+
result = gcs_api_service.list_files_with_prefix(bucket_name, prefix)
91+
92+
assert result == ["file1.txt", "file2.txt"]
93+
mock_client.bucket.assert_called_once_with(bucket_name)
94+
mock_bucket.list_blobs.assert_called_once_with(prefix=prefix)

0 commit comments

Comments
 (0)