From d2923e95beaa61df08e0dad7cccdbf04f80d1ec9 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Wed, 2 Sep 2020 21:08:27 +0200 Subject: New command: update a field in the results of a query --- tests/test_collection.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/test_collection.py') 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') -- cgit v1.2.3