|
2 | 2 | # Licensed under the GPL-3.0 License. |
3 | 3 | # Created for TagStudio: https://github.com/CyanVoxel/TagStudio |
4 | 4 |
|
| 5 | +import shutil |
5 | 6 | from pathlib import Path |
6 | 7 | from tempfile import TemporaryDirectory |
7 | 8 |
|
@@ -29,3 +30,25 @@ def test_refresh_new_files(library: Library, exclude_mode: bool): |
29 | 30 | # Test if the single file was added |
30 | 31 | list(registry.refresh_dir(library_dir, force_internal_tools=True)) |
31 | 32 | assert registry.files_not_in_library == [Path("FOO.MD")] |
| 33 | + |
| 34 | + |
| 35 | +@pytest.mark.parametrize("library", [TemporaryDirectory()], indirect=True) |
| 36 | +def test_refresh_multi_byte_filenames_ripgrep(library: Library): |
| 37 | + assert shutil.which("rg") is not None |
| 38 | + |
| 39 | + library_dir = unwrap(library.library_dir) |
| 40 | + # Given |
| 41 | + registry = RefreshTracker(library=library) |
| 42 | + library.included_files.clear() |
| 43 | + (library_dir / ".TagStudio").mkdir() |
| 44 | + (library_dir / "こんにちは.txt").touch() |
| 45 | + (library_dir / "em–dash.txt").touch() |
| 46 | + (library_dir / "apostrophe’.txt").touch() |
| 47 | + (library_dir / "umlaute äöü.txt").touch() |
| 48 | + |
| 49 | + # Test if all files were added with their correct names and without exceptions |
| 50 | + list(registry.refresh_dir(library_dir)) |
| 51 | + assert Path("こんにちは.txt") in registry.files_not_in_library |
| 52 | + assert Path("em–dash.txt") in registry.files_not_in_library |
| 53 | + assert Path("apostrophe’.txt") in registry.files_not_in_library |
| 54 | + assert Path("umlaute äöü.txt") in registry.files_not_in_library |
0 commit comments