Skip to content
Snippets Groups Projects
Commit a0ea81dc authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

fix

parent 7778607d
No related branches found
No related tags found
1 merge request!8F h5 cfood
Pipeline #10368 passed
This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
...@@ -4,7 +4,7 @@ skip_missing_interpreters = true ...@@ -4,7 +4,7 @@ skip_missing_interpreters = true
[testenv] [testenv]
deps=nose deps=nose
pandas pandas
caosdb git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@dev
pytest pytest
pytest-cov pytest-cov
openpyxl openpyxl
......
...@@ -2,6 +2,7 @@ import unittest ...@@ -2,6 +2,7 @@ import unittest
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
import caosdb as db import caosdb as db
import caosdb.apiutils
import h5py import h5py
import numpy as np import numpy as np
from caosadvancedtools.cfoods import h5 from caosadvancedtools.cfoods import h5
...@@ -21,9 +22,6 @@ def dummy_get(eid): ...@@ -21,9 +22,6 @@ def dummy_get(eid):
return ENTS[eid] return ENTS[eid]
h5.get_entity = dummy_get
class H5CFoodTest(unittest.TestCase): class H5CFoodTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.h5file = NamedTemporaryFile(delete=False, suffix=".h5") self.h5file = NamedTemporaryFile(delete=False, suffix=".h5")
...@@ -76,6 +74,9 @@ class H5CFoodTest(unittest.TestCase): ...@@ -76,6 +74,9 @@ class H5CFoodTest(unittest.TestCase):
self.assertEqual(i.name, "group_level2_aa") self.assertEqual(i.name, "group_level2_aa")
def test_collect_existing_structure(self): 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 # should run without problem
h5.collect_existing_structure(db.Record(), db.Record(id=234), h5.EntityMapping()) h5.collect_existing_structure(db.Record(), db.Record(id=234), h5.EntityMapping())
...@@ -88,8 +89,8 @@ class H5CFoodTest(unittest.TestCase): ...@@ -88,8 +89,8 @@ class H5CFoodTest(unittest.TestCase):
r_target.add_property("test", value=r_child, datatype=db.REFERENCE) r_target.add_property("test", value=r_child, datatype=db.REFERENCE)
em = h5.EntityMapping() em = h5.EntityMapping()
h5.collect_existing_structure(r_target, r_exist, em) h5.collect_existing_structure(r_target, r_exist, em)
self.assertEqual(em.to_existing[r_child._cuid], ENTS[101]) self.assertTrue(em.to_existing[r_child._cuid] is ENTS[101])
self.assertEqual(em.to_target[101], r_child) self.assertTrue(em.to_target[101] is r_child)
# test with retrieval: the existing Record has another Property # test with retrieval: the existing Record has another Property
# -> The referenced Entities are matched # -> The referenced Entities are matched
...@@ -147,6 +148,8 @@ class H5CFoodTest(unittest.TestCase): ...@@ -147,6 +148,8 @@ class H5CFoodTest(unittest.TestCase):
self.assertEqual(em.to_existing[r_child2._cuid], ENTS[101]) self.assertEqual(em.to_existing[r_child2._cuid], ENTS[101])
self.assertEqual(em.to_target[101], r_child2) self.assertEqual(em.to_target[101], r_child2)
caosdb.apiutils.retrieve_entity_with_id = real_retrieve
def test_h5_attr_to_property(self): def test_h5_attr_to_property(self):
test_int: int = 1 test_int: int = 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment