@@ -697,8 +697,39 @@ def test_pyarrow_read_csv_datetime_dtype():
697697 tm .assert_frame_equal (expect , result )
698698
699699
700- def test_iterdir (directory_with_dummy_csv ):
700+ def test_iterdir_local (directory_with_dummy_csv ):
701701 for file in icom .iterdir (directory_with_dummy_csv ):
702702 assert file .is_file ()
703703 assert file .name .startswith ("file_" )
704704 assert file .suffix == ".csv"
705+
706+
707+ def test_mock_remote_csv_directory_contents (mock_remote_csv_directory ):
708+ import fsspec
709+ from fsspec .implementations .memory import MemoryFileSystem
710+
711+ fs = fsspec .filesystem ("s3" )
712+ assert isinstance (fs , MemoryFileSystem )
713+
714+ assert fs .exists ("remote-bucket" )
715+ assert fs .isdir ("remote-bucket" )
716+
717+ files = fs .ls ("remote-bucket" , detail = True )
718+
719+ file_names = sorted (f ["name" ] for f in files if f ["type" ] == "file" )
720+ assert file_names == ["/remote-bucket/a.csv" , "/remote-bucket/b.csv" ]
721+
722+ dir_names = [f ["name" ] for f in files if f ["type" ] == "directory" ]
723+ assert "/remote-bucket/nested" in dir_names
724+
725+ nested_files = fs .ls ("remote-bucket/nested" , detail = True )
726+ assert nested_files [0 ]["name" ] == "/remote-bucket/nested/ignored.csv"
727+
728+
729+ def test_iterdir_remote (mock_remote_csv_directory ):
730+ import fsspec
731+
732+ fs = fsspec .filesystem ("s3" )
733+ for file in icom .iterdir (mock_remote_csv_directory ):
734+ assert fs .isfile (file )
735+ assert file .suffix == ".csv"
0 commit comments