DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
test_configobject.ConfigObject Class Reference
Inheritance diagram for test_configobject.ConfigObject:
[legend]
Collaboration diagram for test_configobject.ConfigObject:
[legend]

Public Member Functions

 test00_CanReadWriteBool (self)
 test01_CanReadWriteInt8 (self)
 test02_CanReadWriteUInt8 (self)
 test03_CanReadWriteInt16 (self)
 test04_CanReadWriteUInt16 (self)
 test05_CanReadWriteInt32 (self)
 test06_CanReadWriteUInt32 (self)
 test07_CanReadWriteInt64 (self)
 test08_CanReadWriteUInt64 (self)
 test08a_CanReadWriteUInt64WithRange (self)
 test09_CanReadWriteString (self)
 test10_CanReadWriteEnum (self)
 test11_CanReadWriteStringList (self)
 test12_CanReadWriteDate (self)
 test13_CanReadWriteTime (self)
 test14_CanReadWriteClassReference (self)
 test15_CanReadWriteSingleValuedRelations (self)
 test16_CanReadWriteMultiValuedRelations (self)
 test17_CanRename (self)

Detailed Description

Definition at line 51 of file test_configobject.py.

Member Function Documentation

◆ test00_CanReadWriteBool()

test_configobject.ConfigObject.test00_CanReadWriteBool ( self)

Definition at line 53 of file test_configobject.py.

53 def test00_CanReadWriteBool(self):
54 limit_test(self, 'bool', False, True)
55

◆ test01_CanReadWriteInt8()

test_configobject.ConfigObject.test01_CanReadWriteInt8 ( self)

Definition at line 56 of file test_configobject.py.

56 def test01_CanReadWriteInt8(self):
57 limit_test(self, 'sint8', -2**7, (2**7)-1)
58 limit_test_raise(self, 'sint8', -2**7, (2**7)-1)
59

◆ test02_CanReadWriteUInt8()

test_configobject.ConfigObject.test02_CanReadWriteUInt8 ( self)

Definition at line 60 of file test_configobject.py.

60 def test02_CanReadWriteUInt8(self):
61 limit_test(self, 'uint8', 0, (2**8)-1)
62 limit_test_raise(self, 'uint8', 0, (2**8)-1)
63

◆ test03_CanReadWriteInt16()

test_configobject.ConfigObject.test03_CanReadWriteInt16 ( self)

Definition at line 64 of file test_configobject.py.

64 def test03_CanReadWriteInt16(self):
65 limit_test(self, 'sint16', -2**15, (2**15)-1)
66 limit_test_raise(self, 'sint16', -2**15, (2**15)-1)
67

◆ test04_CanReadWriteUInt16()

test_configobject.ConfigObject.test04_CanReadWriteUInt16 ( self)

Definition at line 68 of file test_configobject.py.

68 def test04_CanReadWriteUInt16(self):
69 limit_test(self, 'uint16', 0, (2**16)-1)
70 limit_test_raise(self, 'uint16', 0, (2**16)-1)
71

◆ test05_CanReadWriteInt32()

test_configobject.ConfigObject.test05_CanReadWriteInt32 ( self)

Definition at line 72 of file test_configobject.py.

72 def test05_CanReadWriteInt32(self):
73 limit_test(self, 'sint32', -2**31, (2**31)-1)
74 limit_test_raise(self, 'sint32', -2**31, (2**31)-1)
75

◆ test06_CanReadWriteUInt32()

test_configobject.ConfigObject.test06_CanReadWriteUInt32 ( self)

Definition at line 76 of file test_configobject.py.

76 def test06_CanReadWriteUInt32(self):
77 limit_test(self, 'uint32', 0, (2**32)-1)
78 # The next test actually will fail on 32-bit machines if we set the
79 # lower limit to 0. It works OK in other platforms. The bug is related
80 # to the function PyLong_AsUnsignedLongLong() and variants that convert
81 # '-1L' to the highest possible 32-bit unsigned integer not raising an
82 # negative OverflowError as in the other convertions above.
83 # limit_test_raise(self, 'uint32', 0, (2**32)-1)
84

◆ test07_CanReadWriteInt64()

test_configobject.ConfigObject.test07_CanReadWriteInt64 ( self)

Definition at line 85 of file test_configobject.py.

85 def test07_CanReadWriteInt64(self):
86 limit_test(self, 'sint64', -2**63, (2**63)-1)
87 limit_test_raise(self, 'sint64', -2**63, (2**63)-1)
88

◆ test08_CanReadWriteUInt64()

test_configobject.ConfigObject.test08_CanReadWriteUInt64 ( self)

Definition at line 89 of file test_configobject.py.

89 def test08_CanReadWriteUInt64(self):
90 limit_test(self, 'uint64', 0, (2**64)-1)
91 # The next test actually will fail on 64-bit machines if we set the
92 # lower limit to 0. It works OK in other platforms. The bug is related
93 # to the function PyLong_AsUnsignedLongLong() and variants that convert
94 # '-1L' to the highest possible 64-bit unsigned integer not raising an
95 # negative OverflowError as in the other convertions above.
96 # limit_test_raise(self, 'uint64', 0, (2**64)-1)
97

◆ test08a_CanReadWriteUInt64WithRange()

test_configobject.ConfigObject.test08a_CanReadWriteUInt64WithRange ( self)

Definition at line 98 of file test_configobject.py.

98 def test08a_CanReadWriteUInt64WithRange(self):
99 db = conffwk.Configuration("oksconflibs")
100 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
101 t = db.create_obj("Dummy", "TestDummy-1")
102 attrname = 'uint64_vector_range'
103 min = 2**64 - 16
104 max = 2**64 - 1
105 val = [min, max]
106 t[attrname] = val
107 self.assertEqual(t[attrname], val)
108 self.assertRaises(ValueError, t.__setitem__, attrname, [0, 1, 2])
109 db.commit()
110

◆ test09_CanReadWriteString()

test_configobject.ConfigObject.test09_CanReadWriteString ( self)

Definition at line 111 of file test_configobject.py.

111 def test09_CanReadWriteString(self):
112 db = conffwk.Configuration("oksconflibs")
113 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
114 t = db.create_obj("Dummy", "TestDummy-1")
115 val = 'bla'
116 attrname = 'string'
117 t[attrname] = val
118 self.assertEqual(t[attrname], val)
119 db.commit()
120

◆ test10_CanReadWriteEnum()

test_configobject.ConfigObject.test10_CanReadWriteEnum ( self)

Definition at line 121 of file test_configobject.py.

121 def test10_CanReadWriteEnum(self):
122 db = conffwk.Configuration("oksconflibs")
123 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
124 t = db.create_obj("Dummy", "TestDummy-1")
125 val = 'FIRST'
126 attrname = 'enum'
127 t[attrname] = val
128 self.assertEqual(t[attrname], val)
129 val = 'DOES NOT EXIST'
130 self.assertRaises(ValueError, t.__setitem__, attrname, val)
131

◆ test11_CanReadWriteStringList()

test_configobject.ConfigObject.test11_CanReadWriteStringList ( self)

Definition at line 132 of file test_configobject.py.

132 def test11_CanReadWriteStringList(self):
133 db = conffwk.Configuration("oksconflibs")
134 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
135 t = db.create_obj("Dummy", "TestDummy-1")
136 val = ["test10", "test20"]
137 attrname = 'string_vector'
138 t[attrname] = val
139 self.assertEqual(t[attrname], val)
140

◆ test12_CanReadWriteDate()

test_configobject.ConfigObject.test12_CanReadWriteDate ( self)

Definition at line 141 of file test_configobject.py.

141 def test12_CanReadWriteDate(self):
142 db = conffwk.Configuration("oksconflibs")
143 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
144 t = db.create_obj("Dummy", "TestDummy-1")
145 val = "2000-Jan-01"
146 attrname = 'date'
147 t[attrname] = val
148 self.assertEqual(t[attrname], val)
149

◆ test13_CanReadWriteTime()

test_configobject.ConfigObject.test13_CanReadWriteTime ( self)

Definition at line 150 of file test_configobject.py.

150 def test13_CanReadWriteTime(self):
151 db = conffwk.Configuration("oksconflibs")
152 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
153 t = db.create_obj("Dummy", "TestDummy-1")
154 val = "2000-Jan-01 00:00:00"
155 attrname = 'time'
156 t[attrname] = val
157 self.assertEqual(t[attrname], val)
158

◆ test14_CanReadWriteClassReference()

test_configobject.ConfigObject.test14_CanReadWriteClassReference ( self)

Definition at line 159 of file test_configobject.py.

159 def test14_CanReadWriteClassReference(self):
160 db = conffwk.Configuration("oksconflibs")
161 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
162 t = db.create_obj("Dummy", "TestDummy-1")
163 val = 'Second'
164 attrname = 'classref'
165 t[attrname] = val
166 self.assertEqual(t[attrname], val)
167 self.assertRaises(ValueError, t.__setitem__, attrname, 'DoesNotExist')
168 db.commit()
169

◆ test15_CanReadWriteSingleValuedRelations()

test_configobject.ConfigObject.test15_CanReadWriteSingleValuedRelations ( self)

Definition at line 170 of file test_configobject.py.

170 def test15_CanReadWriteSingleValuedRelations(self):
171 db = conffwk.Configuration("oksconflibs")
172 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
173 relation = db.create_obj("Dummy", "Single-Relation")
174 t = db.create_obj('Third', 'Originator')
175 attrname = 'Another'
176 self.assertEqual(t[attrname], None) # problem
177 t[attrname] = relation
178 self.assertEqual(t[attrname], relation)
179 db.commit()
180

◆ test16_CanReadWriteMultiValuedRelations()

test_configobject.ConfigObject.test16_CanReadWriteMultiValuedRelations ( self)

Definition at line 181 of file test_configobject.py.

181 def test16_CanReadWriteMultiValuedRelations(self):
182 db = conffwk.Configuration("oksconflibs")
183 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
184 relations = []
185 for i in range(10):
186 relations.append(db.create_obj("Second", "Relation-%d" % i))
187 t = db.create_obj('Third', 'Originator')
188 attrname = 'Seconds'
189 t[attrname] = relations
190 self.assertEqual(t[attrname], relations)
191 db.commit()
192

◆ test17_CanRename()

test_configobject.ConfigObject.test17_CanRename ( self)

Definition at line 193 of file test_configobject.py.

193 def test17_CanRename(self):
194 db = conffwk.Configuration("oksconflibs")
195 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
196 t = db.create_obj('Dummy', 'TestDummy-1')
197 t.rename('TestDummy-2')
198 self.assertEqual(t.UID(), 'TestDummy-2')
199 t2 = db.get_obj('Dummy', 'TestDummy-2')
200 self.assertEqual(t, t2)
201 db.commit()
202
203

The documentation for this class was generated from the following file: