Skip to content
Snippets Groups Projects

F h5 cfood

Merged Henrik tom Wörden requested to merge f-h5-cfood into dev
2 files
+ 9
6
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 8
5
@@ -2,6 +2,7 @@ import unittest
from tempfile import NamedTemporaryFile
import caosdb as db
import caosdb.apiutils
import h5py
import numpy as np
from caosadvancedtools.cfoods import h5
@@ -21,9 +22,6 @@ def dummy_get(eid):
return ENTS[eid]
h5.get_entity = dummy_get
class H5CFoodTest(unittest.TestCase):
def setUp(self):
self.h5file = NamedTemporaryFile(delete=False, suffix=".h5")
@@ -76,6 +74,9 @@ class H5CFoodTest(unittest.TestCase):
self.assertEqual(i.name, "group_level2_aa")
def test_collect_existing_structure(self):
real_retrieve = caosdb.apiutils.retrieve_entity_with_id
caosdb.apiutils.retrieve_entity_with_id = dummy_get
# should run without problem
h5.collect_existing_structure(db.Record(), db.Record(id=234), h5.EntityMapping())
@@ -88,8 +89,8 @@ class H5CFoodTest(unittest.TestCase):
r_target.add_property("test", value=r_child, datatype=db.REFERENCE)
em = h5.EntityMapping()
h5.collect_existing_structure(r_target, r_exist, em)
self.assertEqual(em.to_existing[r_child._cuid], ENTS[101])
self.assertEqual(em.to_target[101], r_child)
self.assertTrue(em.to_existing[r_child._cuid] is ENTS[101])
self.assertTrue(em.to_target[101] is r_child)
# test with retrieval: the existing Record has another Property
# -> The referenced Entities are matched
@@ -147,6 +148,8 @@ class H5CFoodTest(unittest.TestCase):
self.assertEqual(em.to_existing[r_child2._cuid], ENTS[101])
self.assertEqual(em.to_target[101], r_child2)
caosdb.apiutils.retrieve_entity_with_id = real_retrieve
def test_h5_attr_to_property(self):
test_int: int = 1
Loading