(tempdir)
| 2057 | |
| 2058 | |
| 2059 | def test_copy_files_directory(tempdir): |
| 2060 | localfs = LocalFileSystem() |
| 2061 | |
| 2062 | # create source directory with 2 files |
| 2063 | source_dir = tempdir / "source" |
| 2064 | source_dir.mkdir() |
| 2065 | with localfs.open_output_stream(str(source_dir / "file1")) as f: |
| 2066 | f.write(b'test1') |
| 2067 | with localfs.open_output_stream(str(source_dir / "file2")) as f: |
| 2068 | f.write(b'test2') |
| 2069 | |
| 2070 | def check_copied_files(destination_dir): |
| 2071 | with localfs.open_input_stream(str(destination_dir / "file1")) as f: |
| 2072 | assert f.read() == b"test1" |
| 2073 | with localfs.open_input_stream(str(destination_dir / "file2")) as f: |
| 2074 | assert f.read() == b"test2" |
| 2075 | |
| 2076 | # Copy directory with local file paths |
| 2077 | destination_dir1 = tempdir / "destination1" |
| 2078 | destination_dir1.mkdir() |
| 2079 | copy_files(str(source_dir), str(destination_dir1)) |
| 2080 | check_copied_files(destination_dir1) |
| 2081 | |
| 2082 | # Copy directory with path+filesystem |
| 2083 | destination_dir2 = tempdir / "destination2" |
| 2084 | destination_dir2.mkdir() |
| 2085 | copy_files(str(source_dir), str(destination_dir2), |
| 2086 | source_filesystem=localfs, destination_filesystem=localfs) |
| 2087 | check_copied_files(destination_dir2) |
| 2088 | |
| 2089 | # Copy directory with URI |
| 2090 | destination_dir3 = tempdir / "destination3" |
| 2091 | destination_dir3.mkdir() |
| 2092 | source_uri = _filesystem_uri(str(source_dir)) # file:// |
| 2093 | destination_uri = _filesystem_uri(str(destination_dir3)) |
| 2094 | copy_files(source_uri, destination_uri) |
| 2095 | check_copied_files(destination_dir3) |
| 2096 | |
| 2097 | # Copy directory with Path objects |
| 2098 | destination_dir4 = tempdir / "destination4" |
| 2099 | destination_dir4.mkdir() |
| 2100 | copy_files(source_dir, destination_dir4) |
| 2101 | check_copied_files(destination_dir4) |
| 2102 | |
| 2103 | # copy with additional non-default options |
| 2104 | destination_dir5 = tempdir / "destination5" |
| 2105 | destination_dir5.mkdir() |
| 2106 | copy_files(source_dir, destination_dir5, chunk_size=1, use_threads=False) |
| 2107 | check_copied_files(destination_dir5) |
| 2108 | |
| 2109 | |
| 2110 | @pytest.mark.s3 |
nothing calls this directly
no test coverage detected