Skip to content

Commit 99ded71

Browse files
committed
add windows tests
1 parent 43b560c commit 99ded71

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

server/mergin/tests/test_utils.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from unittest.mock import patch
1313
from pathvalidate import sanitize_filename
1414
from pygeodiff import GeoDiff
15+
from pathlib import PureWindowsPath
1516

1617
from ..utils import save_diagnostic_log_file
1718

@@ -228,15 +229,22 @@ def test_is_valid_path(client, filepath, allow):
228229
assert is_valid_path(filepath) == allow
229230

230231

231-
test_paths = [
232-
("photos /lutraHQ.jpg", True),
233-
("photo s/ lutraHQ.jpg", False),
232+
trailing_spaces_paths = [
233+
("photos /lutraHQ.jpg", "posix", True),
234+
("photo s/ lutraHQ.jpg", "posix", False),
235+
("assets\photos \lutraHQ.jpg", "windows", True),
236+
("assets\ photos\lutraHQ.jpg", "windows", False),
234237
]
235238

236239

237-
@pytest.mark.parametrize("path,result", test_paths)
238-
def test_has_trailing_space(path, result):
239-
assert has_trailing_space(path) is result
240+
@pytest.mark.parametrize("path,path_platform,result", trailing_spaces_paths)
241+
def test_has_trailing_space(path, path_platform, result):
242+
if path_platform == "windows":
243+
# we must mock Path to instantiate as Windows path
244+
with patch("mergin.sync.utils.Path", PureWindowsPath):
245+
assert has_trailing_space(path) is result
246+
else:
247+
assert has_trailing_space(path) is result
240248

241249

242250
def test_get_x_accell_uri(client):

0 commit comments

Comments
 (0)