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 .
This commit is contained in:
Bernhard Reiter 2021-05-19 17:40:04 +02:00
parent 44e4beb06f
commit 804b9f0429
No known key found for this signature in database
GPG key ID: 2B7BA3BF9BC3A554

View file

@ -44,6 +44,25 @@ class TestFilesystemStorage(StorageTests):
(item_file,) = tmpdir.listdir()
assert "/" not in item_file.basename and item_file.isfile()
def test_ignore_tmp_files(self, tmpdir):
"""Test that files with .tmp suffix beside .ics files are ignored."""
s = self.storage_class(str(tmpdir), '.ics')
s.upload(Item('UID:xyzxyz'))
item_file, = tmpdir.listdir()
item_file.copy(item_file.new(ext='tmp'))
assert len(tmpdir.listdir()) == 2
assert len(list(s.list())) == 1
def test_ignore_tmp_files_empty_fileext(self, tmpdir):
"""Test that files with .tmp suffix are ignored with empty fileext."""
s = self.storage_class(str(tmpdir), '')
s.upload(Item('UID:xyzxyz'))
item_file, = tmpdir.listdir()
item_file.copy(item_file.new(ext='tmp'))
assert len(tmpdir.listdir()) == 2
# assert False, tmpdir.listdir() # enable to see the created filename
assert len(list(s.list())) == 1
def test_too_long_uid(self, tmpdir):
s = self.storage_class(str(tmpdir), ".txt")
item = Item("UID:" + "hue" * 600)