Skip to content

Commit 804b9f0

Browse files
Add tests to filesystem storage for file ignorance
that ignore .tmp files even when fileext is empty. Prepares to make the filesystem storage more universal as part of #881 .
1 parent 44e4beb commit 804b9f0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/storage/test_filesystem.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ def test_ident_with_slash(self, tmpdir):
4444
(item_file,) = tmpdir.listdir()
4545
assert "/" not in item_file.basename and item_file.isfile()
4646

47+
def test_ignore_tmp_files(self, tmpdir):
48+
"""Test that files with .tmp suffix beside .ics files are ignored."""
49+
s = self.storage_class(str(tmpdir), '.ics')
50+
s.upload(Item('UID:xyzxyz'))
51+
item_file, = tmpdir.listdir()
52+
item_file.copy(item_file.new(ext='tmp'))
53+
assert len(tmpdir.listdir()) == 2
54+
assert len(list(s.list())) == 1
55+
56+
def test_ignore_tmp_files_empty_fileext(self, tmpdir):
57+
"""Test that files with .tmp suffix are ignored with empty fileext."""
58+
s = self.storage_class(str(tmpdir), '')
59+
s.upload(Item('UID:xyzxyz'))
60+
item_file, = tmpdir.listdir()
61+
item_file.copy(item_file.new(ext='tmp'))
62+
assert len(tmpdir.listdir()) == 2
63+
# assert False, tmpdir.listdir() # enable to see the created filename
64+
assert len(list(s.list())) == 1
65+
4766
def test_too_long_uid(self, tmpdir):
4867
s = self.storage_class(str(tmpdir), ".txt")
4968
item = Item("UID:" + "hue" * 600)

0 commit comments

Comments
 (0)