master/databases: fix AttributeError in DatasetDB.set()

Add corresponding unit test.

Signed-off-by: Etienne Wodey <wodey@iqo.uni-hannover.de>
This commit is contained in:
Etienne Wodey 2021-06-17 16:30:38 +02:00
parent d8b1e59538
commit 12ef907f34
2 changed files with 13 additions and 1 deletions

View File

@ -90,7 +90,7 @@ class DatasetDB(TaskObject):
def set(self, key, value, persist=None, **hdf5_options):
if persist is None:
if key in self.data.raw_view:
persist = self.data.raw_view[key].persist
persist = self.data.raw_view[key]["persist"]
else:
persist = False
self.data[key] = make_dataset(

View File

@ -97,3 +97,15 @@ class TestDatasetDB(unittest.TestCase):
self.ddb.update(mod)
self.assertFalse(self.ddb.get(KEY1)["hdf5_options"]["shuffle"])
def test_reset_copies_persist(self):
self.assertTrue(self.ddb.get(KEY1)["persist"])
self.ddb.set(KEY1, DATA)
self.assertTrue(self.ddb.get(KEY1)["persist"])
self.assertFalse(self.ddb.get(KEY3)["persist"])
self.ddb.set(KEY3, DATA)
self.assertFalse(self.ddb.get(KEY3)["persist"])
self.ddb.set(KEY3, DATA, persist=True)
self.assertTrue(self.ddb.get(KEY3)["persist"])