24 lines
1,017 B
Python
24 lines
1,017 B
Python
#!/usr/bin/env python3
|
|
|
|
from wolkje_files import file_name
|
|
|
|
|
|
def test_set_extension():
|
|
assert file_name.set_extension("", ".jpg") == ".jpg"
|
|
assert file_name.set_extension("foo", ".jpg") == "foo.jpg"
|
|
assert file_name.set_extension("foo.", ".jpg") == "foo.jpg"
|
|
assert file_name.set_extension("foo.bar", ".jpg") == "foo.jpg"
|
|
assert file_name.set_extension("foo.tar.gz", ".jpg") == "foo.jpg"
|
|
assert file_name.set_extension("foo.tafel", ".jpg") == "foo.jpg"
|
|
assert file_name.set_extension("foo.tafels", ".jpg") == "foo.tafels.jpg"
|
|
|
|
|
|
def test_sanitize():
|
|
assert file_name.sanitize("foo.jpg") == "foo.jpg"
|
|
assert file_name.sanitize("foo/bar.jpg") == "foo-bar.jpg"
|
|
assert file_name.sanitize("foo bar (1).jpg") == "foo bar (1).jpg"
|
|
assert file_name.sanitize("foo/bar (1).jpg") == "foo-bar (1).jpg"
|
|
assert file_name.sanitize(".foo/bar (1).jpg") == "foo-bar (1).jpg"
|
|
assert file_name.sanitize("..foo/bar (1).jpg") == "foo-bar (1).jpg"
|
|
assert file_name.sanitize("..") is None
|
|
assert file_name.sanitize("") is None
|