aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-09-02 21:08:27 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-09-02 21:08:27 +0200
commitd2923e95beaa61df08e0dad7cccdbf04f80d1ec9 (patch)
treeedf5ff4359d159cf9b29b28ebe455ae2969774ab /tests
parentc96febf5d0a272b215397869f6a3569b9a8b8382 (diff)
New command: update a field in the results of a query
Diffstat (limited to 'tests')
-rw-r--r--tests/test_collection.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index e97e912..eb57fb0 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -154,6 +154,38 @@ class testCollection(unittest.TestCase):
self.assertIn('11189ee4: Another item', res)
+class testSimpleCollection(unittest.TestCase):
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+ shutil.copytree('tests/data/simple', self.tmpdir, dirs_exist_ok=True)
+ self.collection = lesana.Collection(self.tmpdir)
+
+ def tearDown(self):
+ shutil.rmtree(self.tmpdir)
+
+ def test_update(self):
+ self.collection.update_field('Item', field="position", value="new_pos")
+ with open(os.path.join(
+ self.collection.basedir,
+ 'items',
+ '11189ee47ddf4796b718a483b379f976.yaml'
+ )) as fp:
+ self.assertIn("new_pos", fp.read())
+ pass
+ self.assertEqual(
+ self.collection.entry_from_eid(
+ "11189ee47ddf4796b718a483b379f976"
+ ).data['position'],
+ "new_pos"
+ )
+
+ self.assertIsNone(
+ self.collection.entry_from_eid(
+ "8b69b063b2a64db7b5714294a69255c7"
+ ).data['position']
+ )
+
+
class testEntries(unittest.TestCase):
def setUp(self):
self.collection = lesana.Collection('tests/data/simple')