@@ -191,6 +191,52 @@ def test_obj_single_file_single_bucket_with_prefix(
191191 assert f1 .read () == f2 .read ()
192192
193193
194+ def test_obj_single_file_single_bucket_with_prefix_ltrim (
195+ create_bucket : Callable [[Optional [str ]], str ],
196+ generate_test_files : GetTestFilesType ,
197+ keys : Keys ,
198+ monkeypatch : MonkeyPatch ,
199+ ):
200+ patch_keys (keys , monkeypatch )
201+ file_path = generate_test_files ()[0 ]
202+ bucket_name = create_bucket ()
203+ # using 'bk' in prefix to test out ltrim behaviour (bucket contains 'bk')
204+ exec_test_command (
205+ BASE_CMD + ["put" , str (file_path ), f"{ bucket_name } /bkprefix" ]
206+ )
207+ process = exec_test_command (BASE_CMD + ["la" ])
208+ output = process .stdout .decode ()
209+
210+ assert f"{ bucket_name } /bkprefix/{ file_path .name } " in output
211+
212+ file_size = file_path .stat ().st_size
213+ assert str (file_size ) in output
214+
215+ process = exec_test_command (BASE_CMD + ["ls" ])
216+ output = process .stdout .decode ()
217+ assert bucket_name in output
218+ assert file_path .name not in output
219+
220+ process = exec_test_command (BASE_CMD + ["ls" , bucket_name ])
221+ output = process .stdout .decode ()
222+ assert bucket_name not in output
223+ assert "bkprefix" in output
224+
225+ downloaded_file_path = file_path .parent / f"downloaded_{ file_path .name } "
226+ process = exec_test_command (
227+ BASE_CMD
228+ + [
229+ "get" ,
230+ bucket_name ,
231+ "bkprefix/" + file_path .name ,
232+ str (downloaded_file_path ),
233+ ]
234+ )
235+ output = process .stdout .decode ()
236+ with open (downloaded_file_path ) as f2 , open (file_path ) as f1 :
237+ assert f1 .read () == f2 .read ()
238+
239+
194240def test_multi_files_multi_bucket (
195241 create_bucket : Callable [[Optional [str ]], str ],
196242 generate_test_files : GetTestFilesType ,
0 commit comments