summaryrefslogtreecommitdiff
path: root/tests/test_collection.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-11-17 16:51:56 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2019-11-17 16:51:56 +0100
commitf9756feaffb808b904eab2ba177c42d121ccda48 (patch)
tree2d468da61d04feb46d917bc032b397705082a08f /tests/test_collection.py
parent9355c5d40a3b21c0ba95a423ffa4629111148dbe (diff)
Delete entry by short id.
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r--tests/test_collection.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 4160c5e..ab6d807 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -412,6 +412,31 @@ class testCollectionCreation(unittest.TestCase):
mset = collection._enquire.get_mset(0, 10)
self.assertEqual(mset.get_matches_estimated(), 0)
+ def test_partial_deletion(self):
+ tmpdir = tempfile.mkdtemp()
+ shutil.copy('tests/data/simple/settings.yaml', tmpdir)
+ shutil.copytree(
+ 'tests/data/simple/items',
+ os.path.join(tmpdir, 'items'),
+ )
+ collection = lesana.Collection.init(tmpdir)
+ # We start with one item indexed with the term "another"
+ collection.start_search('another')
+ mset = collection._enquire.get_mset(0, 10)
+ self.assertEqual(mset.get_matches_estimated(), 1)
+ # Then delete it, using the short id
+ collection.remove_entries(['11189ee4'])
+ # An now we should have none
+ self.assertFalse(os.path.exists(os.path.join(
+ tmpdir,
+ 'items',
+ '11189ee47ddf4796b718a483b379f976.yaml'
+ )))
+ collection.start_search('another')
+ mset = collection._enquire.get_mset(0, 10)
+ self.assertEqual(mset.get_matches_estimated(), 0)
+
+
def _find_file_in_git_index(self, fname, index):
found = False
for (path, stage) in index.entries: