Improve storage/test_filesystem

with one additional test and fixing of the documentation.
This commit is contained in:
Bernhard Reiter 2021-05-20 12:50:05 +02:00
parent 81895c291e
commit 9b5e01ab38
No known key found for this signature in database
GPG key ID: 2B7BA3BF9BC3A554
2 changed files with 13 additions and 2 deletions

View file

@ -408,7 +408,7 @@ Local
fileext = "..." fileext = "..."
#encoding = "utf-8" #encoding = "utf-8"
#post_hook = null #post_hook = null
#fileextignore = ".tmp" #fileignoreext = ".tmp"
Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for Can be used with `khal <http://lostpackets.de/khal/>`_. See :doc:`vdir` for
a more formal description of the format. a more formal description of the format.
@ -427,7 +427,7 @@ Local
:param post_hook: A command to call for each item creation and :param post_hook: A command to call for each item creation and
modification. The command will be called with the path of the modification. The command will be called with the path of the
new/updated file. new/updated file.
:param fileextignore: The file extention to ignore, :param fileeignoreext: The file extention to ignore,
the default is ``.tmp``. the default is ``.tmp``.
.. storage:: singlefile .. storage:: singlefile

View file

@ -63,6 +63,17 @@ class TestFilesystemStorage(StorageTests):
# assert False, tmpdir.listdir() # enable to see the created filename # assert False, tmpdir.listdir() # enable to see the created filename
assert len(list(s.list())) == 1 assert len(list(s.list())) == 1
def test_ignore_files_typical_backup(self, tmpdir):
"""Test file-name ignorance with typical backup ending ~."""
ignorext = "~" # without dot
s = self.storage_class(str(tmpdir), '', fileignoreext="~")
s.upload(Item('UID:xyzxyz'))
item_file, = tmpdir.listdir()
item_file.copy(item_file.new(basename=item_file.basename+'~'))
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): def test_too_long_uid(self, tmpdir):
s = self.storage_class(str(tmpdir), ".txt") s = self.storage_class(str(tmpdir), ".txt")
item = Item("UID:" + "hue" * 600) item = Item("UID:" + "hue" * 600)