File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
packages/happtiq_commons_google_cloud/tests/happtiq_commons_google_cloud Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -74,3 +74,21 @@ def test_upload_file_gzipped(gcs_api_service, monkeypatch):
74
74
gcs_api_service .client .bucket ().blob .assert_called_once_with (destination )
75
75
gcs_api_service .client .bucket ().blob (destination ).upload_from_filename .assert_called_once_with (file_path , content_type = content_type , timeout = 30 )
76
76
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 )
You can’t perform that action at this time.
0 commit comments