|
1 | | -"""Tests for utils.path_helpers path/timestamp helpers (closes #46). |
| 1 | +"""Tests for utils.path_helpers path/timestamp helpers (closes #44, #46). |
2 | 2 |
|
3 | 3 | Covers ``normalize_file_path`` and ``to_epoch_ms``, both previously duplicated |
4 | 4 | in scripts/export.py. All call-sites in the web app and CLI export script now |
5 | 5 | use the shared implementations in utils.path_helpers. |
6 | 6 |
|
7 | | -Test inventory (this module only): 21 cases — 12 ``normalize_file_path``, |
| 7 | +Test inventory (this module only): 24 cases — 15 ``normalize_file_path``, |
8 | 8 | 9 ``to_epoch_ms``. On win32, 2 cases skip (POSIX passthrough in |
9 | | -``TestNormalizeFilePathPosixPassthrough`` only). A full-suite run may report |
10 | | -more skips (e.g. ``skipped=4``) from other test modules, not this file. |
| 9 | +``TestNormalizeFilePathPosixPassthrough`` only). On non-win32, 3 cases skip |
| 10 | +(``TestNormalizeFilePathWindowsNative`` — exercised on windows-latest CI). |
| 11 | +A full-suite run may report more skips (e.g. ``skipped=4``) from other test |
| 12 | +modules, not this file. |
11 | 13 | """ |
12 | 14 |
|
13 | 15 | import sys |
@@ -91,6 +93,25 @@ def test_mixed_case_drive_lowercased(self) -> None: |
91 | 93 | self.assertEqual(out, r"e:\mixed\case\path") |
92 | 94 |
|
93 | 95 |
|
| 96 | +class TestNormalizeFilePathWindowsNative(unittest.TestCase): |
| 97 | + """Win32-only edge cases — run on actual Windows runners in CI (#44).""" |
| 98 | + |
| 99 | + @unittest.skipUnless(sys.platform == "win32", "native win32 path semantics") |
| 100 | + def test_leading_backslash_before_drive_stripped(self) -> None: |
| 101 | + out = normalize_file_path(r"\C:\Users\Dev\project") |
| 102 | + self.assertEqual(out, r"c:\users\dev\project") |
| 103 | + |
| 104 | + @unittest.skipUnless(sys.platform == "win32", "native win32 path semantics") |
| 105 | + def test_file_uri_backslashes_normalised(self) -> None: |
| 106 | + out = normalize_file_path(r"file:///C:\Users\Dev\project") |
| 107 | + self.assertEqual(out, r"c:\users\dev\project") |
| 108 | + |
| 109 | + @unittest.skipUnless(sys.platform == "win32", "native win32 path semantics") |
| 110 | + def test_percent_encoded_drive_on_win32(self) -> None: |
| 111 | + out = normalize_file_path("/d%3A/_Work/project") |
| 112 | + self.assertEqual(out, r"d:\_work\project") |
| 113 | + |
| 114 | + |
94 | 115 | class TestNormalizeFilePathPosixPassthrough(unittest.TestCase): |
95 | 116 | def test_plain_posix_path_unchanged_on_non_windows(self) -> None: |
96 | 117 | if sys.platform == "win32": |
|
0 commit comments