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

Public Member Functions

 test01_CanCreateDB (self)
 
 test01a_DoesNotCrashIfDBNotThere (self)
 
 test02_CanReopenDB (self)
 
 test03_CanAddIncludes (self)
 
 test04_CanRemoveIncludes (self)
 
 test05_CanCreateObject (self)
 
 test05a_CanCreateObjectFromOtherObject (self)
 
 test06_CanTestForObjects (self)
 
 test07_DetectsExistingObjects (self)
 
 test08_CanGetObject (self)
 
 test08a_CanGetObjects (self)
 
 test09_DoesNotCrashIfNonExisting (self)
 
 test10_CanRemoveObject (self)
 
 test11_CanCycleThroughStates (self)
 
 test12_CanStuffThousands (self)
 
 test13_CanCommitDeepRelations (self)
 
 test14_CanRetrieveDeepRelations (self)
 
 test15_CommitWithComment (self)
 

Detailed Description

Tests if we can manipulate ConfigurationWrap objects as expected.

Definition at line 12 of file test_configuration.py.

Member Function Documentation

◆ test01_CanCreateDB()

test_configuration.Configuration.test01_CanCreateDB ( self)

Definition at line 15 of file test_configuration.py.

15 def test01_CanCreateDB(self):
16 db = conffwk.Configuration("oksconflibs")
17 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
18 db.commit()
19

◆ test01a_DoesNotCrashIfDBNotThere()

test_configuration.Configuration.test01a_DoesNotCrashIfDBNotThere ( self)

Definition at line 20 of file test_configuration.py.

20 def test01a_DoesNotCrashIfDBNotThere(self):
21 self.assertRaises(RuntimeError, conffwk.Configuration, "test2.data.xml")
22

◆ test02_CanReopenDB()

test_configuration.Configuration.test02_CanReopenDB ( self)

Definition at line 23 of file test_configuration.py.

23 def test02_CanReopenDB(self):
24 db = conffwk.Configuration("oksconflibs:test.data.xml")
25 includes = db.get_includes("test.data.xml")
26 self.assertEqual(len(includes), 1)
27 self.assertEqual(includes[0], f"{scriptsdir}/test.schema.xml")
28

◆ test03_CanAddIncludes()

test_configuration.Configuration.test03_CanAddIncludes ( self)

Definition at line 29 of file test_configuration.py.

29 def test03_CanAddIncludes(self):
30 db = conffwk.Configuration("oksconflibs:test.data.xml")
31 db.add_include(f'{scriptsdir}/core.schema.xml')
32 includes = db.get_includes("test.data.xml")
33 print(includes)
34 self.assertEqual(len(includes), 2)
35 db.commit()
36 includes = db.get_includes("test.data.xml")
37 self.assertEqual(len(includes), 2)
38

◆ test04_CanRemoveIncludes()

test_configuration.Configuration.test04_CanRemoveIncludes ( self)

Definition at line 39 of file test_configuration.py.

39 def test04_CanRemoveIncludes(self):
40 db = conffwk.Configuration("oksconflibs:test.data.xml")
41 includes = db.get_includes()
42 self.assertEqual(len(includes), 2)
43 db.remove_include(includes[1])
44 db.commit()
45 includes = db.get_includes()
46 self.assertEqual(len(includes), 1)
47

◆ test05_CanCreateObject()

test_configuration.Configuration.test05_CanCreateObject ( self)

Definition at line 48 of file test_configuration.py.

48 def test05_CanCreateObject(self):
49 db = conffwk.Configuration("oksconflibs:test.data.xml")
50 for i in range(10):
51 db.create_obj("Dummy", "TestDummy-%d" % i)
52 db.commit()
53

◆ test05a_CanCreateObjectFromOtherObject()

test_configuration.Configuration.test05a_CanCreateObjectFromOtherObject ( self)

Definition at line 54 of file test_configuration.py.

54 def test05a_CanCreateObjectFromOtherObject(self):
55 db = conffwk.Configuration("oksconflibs:test.data.xml")
56 master = db.create_obj("Dummy", "MasterDummy")
57 for i in range(100, 110):
58 db.create_obj("Dummy", "TestDummy-%d" % i)
59 db.commit()
60

◆ test06_CanTestForObjects()

test_configuration.Configuration.test06_CanTestForObjects ( self)

Definition at line 61 of file test_configuration.py.

61 def test06_CanTestForObjects(self):
62 db = conffwk.Configuration("oksconflibs:test.data.xml")
63 for i in range(10):
64 self.assertTrue(db.test_object("Dummy", "TestDummy-%d" % i, 0, []))
65 for i in range(1000, 1010):
66 self.assertTrue(not db.test_object("Dummy", "TestDummy-%d" % i, 0, []))
67

◆ test07_DetectsExistingObjects()

test_configuration.Configuration.test07_DetectsExistingObjects ( self)

Definition at line 68 of file test_configuration.py.

68 def test07_DetectsExistingObjects(self):
69 db = conffwk.Configuration("oksconflibs:test.data.xml")
70 self.assertRaises(RuntimeError, db.create_obj, "Dummy", "TestDummy-3")
71

◆ test08_CanGetObject()

test_configuration.Configuration.test08_CanGetObject ( self)

Definition at line 72 of file test_configuration.py.

72 def test08_CanGetObject(self):
73 db = conffwk.Configuration("oksconflibs:test.data.xml")
74 obj = db.get_obj("Dummy", "TestDummy-4")
75

◆ test08a_CanGetObjects()

test_configuration.Configuration.test08a_CanGetObjects ( self)

Definition at line 76 of file test_configuration.py.

76 def test08a_CanGetObjects(self):
77 db = conffwk.Configuration("oksconflibs:test.data.xml")
78 objs = db.get_objs("Dummy")
79 self.assertEqual(len(objs), 21)
80

◆ test09_DoesNotCrashIfNonExisting()

test_configuration.Configuration.test09_DoesNotCrashIfNonExisting ( self)

Definition at line 81 of file test_configuration.py.

81 def test09_DoesNotCrashIfNonExisting(self):
82 db = conffwk.Configuration("oksconflibs:test.data.xml")
83 self.assertRaises(RuntimeError, db.get_obj, "Dummy", "TestDummy-44")
84

◆ test10_CanRemoveObject()

test_configuration.Configuration.test10_CanRemoveObject ( self)

Definition at line 85 of file test_configuration.py.

85 def test10_CanRemoveObject(self):
86 db = conffwk.Configuration("oksconflibs:test.data.xml")
87 obj = db.get_obj("Dummy", "TestDummy-1")
88 db.destroy_obj(obj)
89 db.commit()
90 self.assertRaises(RuntimeError, db.get_obj, "Dummy", "TestDummy-1")
91

◆ test11_CanCycleThroughStates()

test_configuration.Configuration.test11_CanCycleThroughStates ( self)

Definition at line 92 of file test_configuration.py.

92 def test11_CanCycleThroughStates(self):
93 db = conffwk.Configuration("oksconflibs:test.data.xml")
94 self.assertTrue(db.loaded())
95 db.unload()
96 self.assertTrue(not db.loaded())
97 db.load("test.data.xml")
98 self.assertTrue(db.loaded())
99 db.unload()
100 self.assertTrue(not db.loaded())
101

◆ test12_CanStuffThousands()

test_configuration.Configuration.test12_CanStuffThousands ( self)

Definition at line 102 of file test_configuration.py.

102 def test12_CanStuffThousands(self):
103 amount = 10000
104 db = conffwk.Configuration("oksconflibs")
105 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
106 for i in range(amount):
107 db.create_obj("Dummy", "TestDummy-%d" % i)
108 db.commit()
109

◆ test13_CanCommitDeepRelations()

test_configuration.Configuration.test13_CanCommitDeepRelations ( self)

Definition at line 110 of file test_configuration.py.

110 def test13_CanCommitDeepRelations(self):
111 import sys
112 sys.setrecursionlimit(10000)
113
114 depth = 10000
115 db = conffwk.Configuration("oksconflibs")
116 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
117 previous = None
118 for i in range(depth):
119 obj = db.create_obj("Second", "Object-%d" % i)
120 if previous:
121 obj['Another'] = previous
122 previous = obj
123 db.commit()
124
125

◆ test14_CanRetrieveDeepRelations()

test_configuration.Configuration.test14_CanRetrieveDeepRelations ( self)

Definition at line 128 of file test_configuration.py.

128 def test14_CanRetrieveDeepRelations(self):
129 # we test if one can leave the rlevel in gets() to "0" and that works
130 import sys
131 sys.setrecursionlimit(10000)
132
133 depth = 10000
134 db = conffwk.Configuration('oksconflibs:test.data.xml')
135 # gets the topmost obj.
136 obj = db.get_obj('Second', 'Object-%d' % (depth-1))
137 counter = 1
138
139 while obj['Another']:
140 counter += 1
141 obj = obj['Another'] # go deep in the relationship
142 self.assertEqual(counter, depth)
143

◆ test15_CommitWithComment()

test_configuration.Configuration.test15_CommitWithComment ( self)

Definition at line 144 of file test_configuration.py.

144 def test15_CommitWithComment(self):
145 db = conffwk.Configuration("oksconflibs")
146 dbfile = 'testcomment.data.xml'
147 db.create_db(dbfile, [f'{scriptsdir}/test.schema.xml'])
148 comment = "My test comment"
149 db.commit(comment)
150 del db
151 with open(dbfile) as textfile:
152 line = [l for l in textfile if ' <comment ' in l][0]
153
154 element = line.splitlines()[0]
155 self.assertTrue(comment in element)
156
157

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