12from ROOT
import Belle2
18class PythonDataStoreTests(unittest.TestCase):
20 def test_PyStoreObj(self):
23 objList = (testObj, persistentObj)
29 self.assertTrue(
not obj)
30 self.assertTrue(
not obj.create())
33 self.assertTrue(
not obj.registerInDataStore())
36 self.assertTrue(
not obj)
42 def test_PyStoreObj_with_known_class(self):
47 self.assertTrue(eventMetaData.registerInDataStore())
49 self.assertFalse(eventMetaData.isValid())
50 eventMetaData.create()
51 self.assertTrue(eventMetaData.isValid())
54 eventMetaData.setExperiment(17)
58 self.assertTrue(eventMetaData2.isValid())
59 self.assertEqual(17, eventMetaData.getExperiment())
65 def test_PyStoreArray(self):
73 for array
in arrayList:
74 self.assertTrue(
not array)
75 self.assertEqual(0, array.getEntries())
76 self.assertEqual(0, len(array))
78 self.assertTrue(
not array[1234])
79 self.assertTrue(
not array.appendNew())
80 self.assertEqual(0, len(array))
82 def test_EnumBackwardsCompatibility(self):
83 self.assertEqual(0, Belle2.DataStore.c_Event)
84 self.assertEqual(1, Belle2.DataStore.c_Persistent)
87 def test_PyStoreArray_with_known_class(self):
91 self.assertTrue(array.registerInDataStore(
"RelationsObjects"))
92 self.assertEqual(
"RelationsObjects", array.getName())
96 self.assertEqual(
"OtherRelationsObjects", otherArray.getName())
97 self.assertTrue(otherArray.registerInDataStore())
99 array.registerRelationTo(otherArray)
101 self.assertTrue(array.hasRelationTo(otherArray))
102 self.assertTrue(otherArray.hasRelationFrom(array))
103 self.assertFalse(array.hasRelationFrom(otherArray))
104 self.assertFalse(otherArray.hasRelationTo(array))
106 obj = array.appendNew()
108 self.assertEqual(1, len(array))
109 self.assertTrue(array[0])
116 self.assertTrue(
False)
118 otherObject = otherArray.appendNew()
119 obj.addRelationTo(otherObject)
127 otherArray2.isRequired()
129 self.assertEqual(1, len(array2))
130 self.assertEqual(1, len(otherArray2))
132 array2.requireRelationTo(otherArray2)
134 self.assertEqual(obj, obj2)
136 otherObject2 = obj2.getRelated(
"OtherRelationsObjects")
137 self.assertEqual(otherObject, otherObject2)
140if __name__ ==
"__main__":
141 basf2.B2INFO(
"Following error messages are expected, please ignore.")
143 basf2.B2INFO(
"Previous errors are expected, please ignore.")
A (simplified) python wrapper for StoreArray.
static std::vector< std::string > list(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Return list of available arrays for given durability.
a (simplified) python wrapper for StoreObjPtr.
static std::vector< std::string > list(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Return list of available objects for given durability.