Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
# Copyright (C) 2016-2022 The Software Heritage developers | # Copyright (C) 2016-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import itertools | |||||
import logging | import logging | ||||
import os | import os | ||||
import shutil | import shutil | ||||
import subprocess | import subprocess | ||||
import textwrap | import textwrap | ||||
from typing import Any, Dict | from typing import Any, Dict | ||||
import pytest | import pytest | ||||
▲ Show 20 Lines • Show All 2,156 Lines • ▼ Show 20 Lines | assert_last_visit_matches( | ||||
repo_url, | repo_url, | ||||
status="full", | status="full", | ||||
type="svn", | type="svn", | ||||
) | ) | ||||
check_snapshot(loader.snapshot, loader.storage) | check_snapshot(loader.snapshot, loader.storage) | ||||
@pytest.mark.parametrize( | def test_loader_with_special_chars_in_svn_url(repo_url, tmp_path): | ||||
"filename", ["file with spaces.txt", "file#with#hash#signs.txt"] | |||||
) | |||||
def test_loader_with_special_chars_in_svn_url(repo_url, tmp_path, filename): | |||||
content = b"foo" | content = b"foo" | ||||
filename = "".join( | |||||
itertools.chain( | |||||
(chr(i) for i in range(32, 127)), (chr(i) for i in range(161, 256)) | |||||
) | |||||
vlorentz: that gives you a superset, which also contains whitespace:
```
>>> import string
>>> {chr(i)… | |||||
Done Inline ActionsThose characters cannot be in a subversion filename (I got this type of error message Invalid control character '0x0b' in path) so that's why I used a subset here. anlambert: Those characters cannot be in a subversion filename (I got this type of error message `Invalid… | |||||
) | |||||
add_commit( | add_commit( | ||||
repo_url, | repo_url, | ||||
"Add file with spaces in its name", | "Add file with characters to quote in its name", | ||||
[ | [ | ||||
CommitChange( | CommitChange( | ||||
change_type=CommitChangeType.AddOrUpdate, | change_type=CommitChangeType.AddOrUpdate, | ||||
path=filename, | path=filename, | ||||
data=content, | data=content, | ||||
), | ), | ||||
], | ], | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
that gives you a superset, which also contains whitespace: