summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-29 10:17:11 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2021-12-29 10:18:10 +0100
commitbd5a6fe58cd739ea7d36cc9d37730adc4f688025 (patch)
tree3f6dade91331e0eb0a4a1ff50661d1dd37f18cbe
parentd40cc993c199f58031cb4f25b9f9b21ac3b0bafe (diff)
Fix rm command test (and others) by indexing the collection at the beginning
-rw-r--r--lesana/collection.py4
-rw-r--r--tests/test_commands.py25
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