From 1ab41af4cdce777c3f5b0e0f985e5846999b9010 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 14 Jan 2017 10:30:18 +0100 Subject: New command: remove --- tests/test_collection.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/test_collection.py') diff --git a/tests/test_collection.py b/tests/test_collection.py index 3959399..a37a696 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -230,6 +230,30 @@ class testCollectionCreation(unittest.TestCase): self.assertFalse(os.path.isfile(os.path.join(tmpdir, '.gitignore'))) shutil.rmtree(tmpdir) + def test_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 + collection.remove_entries(['11189ee47ddf4796b718a483b379f976']) + # 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) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3