From f9756feaffb808b904eab2ba177c42d121ccda48 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sun, 17 Nov 2019 16:51:56 +0100 Subject: Delete entry by short id. --- tests/test_collection.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') 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: -- cgit v1.2.3