-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtests.py
44 lines (36 loc) · 1.06 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import pytest
from downloader import Downloader
@pytest.mark.parametrize(
("part", "expected"),
[
# -.@!
("a-b", "a-b"),
("a.b", "a.b"),
("a@b", "a@b"),
("a!b", "a!b"),
("a1b", "a1b"),
# Windows reserved
("a<b", "a-b"),
("a>b", "a-b"),
("a:b", "a-b"),
('a"b', "a-b"),
("a/b", "a-b"),
("a\\b", "a-b"),
("a|b", "a-b"),
("a?b", "a-b"),
("a*b", "a-b"),
# Windows special dirs see https://docs.microsoft.com/en-gb/windows/win32/fileio/naming-a-file
# ("CON", "_CON_")
],
)
def test__filter_filename_part(part, expected):
assert Downloader.filter_filename_part(part) == expected
@pytest.fixture
def downloader():
return Downloader(".")
@pytest.mark.parametrize(
("url", "expected_filename"), [("http://example.com/seq-427.ts", os.path.join(".", "example.com", "seq-427.ts"))]
)
def test__uri_to_filename(url, expected_filename, downloader):
assert downloader.uri_to_filename(url) == expected_filename