diff options
-rw-r--r-- | lesana/collection.py | 4 | ||||
-rw-r--r-- | tests/test_commands.py | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lesana/collection.py b/lesana/collection.py index d49512a..7ab4334 100644 --- a/lesana/collection.py +++ b/lesana/collection.py @@ -510,7 +510,9 @@ class Collection(object): cache.delete_document(entry.idterm) self.remove_file(entry.fname) else: - logger.warning("No such entry: {}, ignoring".format(eid)) + logger.warning("Not removing {}: no such entry".format( + eid + )) cache.commit() cache.close() diff --git a/tests/test_commands.py b/tests/test_commands.py index 91a8894..2f3fa8c 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -47,6 +47,13 @@ class testCommandsSimple(unittest.TestCase, CommandsMixin): self.tmpdir.name, dirs_exist_ok=True, ) + # re-index the collection before running each test + args = { + 'collection': self.tmpdir.name, + "files": None, + "reset": True, + } + self._run_command(command.Index(), args) def tearDown(self): pass @@ -163,11 +170,20 @@ class testCommandsSimple(unittest.TestCase, CommandsMixin): args = { 'collection': self.tmpdir.name, 'git': True, - 'entries': '11189ee4', + 'entries': ['11189ee4'], } streams = self._run_command(command.Remove(), args) self.assertEqual(streams['stdout'].getvalue(), '') self.assertEqual(streams['stderr'].getvalue(), '') + # and check that the entry has been removed + args = { + 'collection': self.tmpdir.name, + 'git': True, + 'eid': '11189ee4', + 'template': False, + } + streams = self._run_command(command.Show(), args) + self.assertEqual(streams['stderr'].getvalue(), '') def test_update(self): args = { @@ -190,6 +206,13 @@ class testCommandsComplex(unittest.TestCase, CommandsMixin): self.tmpdir.name, dirs_exist_ok=True, ) + # re-index the collection before running each test + args = { + 'collection': self.tmpdir.name, + "files": None, + "reset": True, + } + self._run_command(command.Index(), args) def tearDown(self): pass |