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 17 of file test_configuration.py.

Member Function Documentation

◆ test01_CanCreateDB()

test_configuration.Configuration.test01_CanCreateDB ( self)

Definition at line 20 of file test_configuration.py.

20 def test01_CanCreateDB(self):
21 db = conffwk.Configuration("oksconflibs")
22 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
23 db.commit()
24

◆ test01a_DoesNotCrashIfDBNotThere()

test_configuration.Configuration.test01a_DoesNotCrashIfDBNotThere ( self)

Definition at line 25 of file test_configuration.py.

25 def test01a_DoesNotCrashIfDBNotThere(self):
26 self.assertRaises(RuntimeError, conffwk.Configuration, "test2.data.xml")
27

◆ test02_CanReopenDB()

test_configuration.Configuration.test02_CanReopenDB ( self)

Definition at line 28 of file test_configuration.py.

28 def test02_CanReopenDB(self):
29 db = conffwk.Configuration("oksconflibs:test.data.xml")
30 includes = db.get_includes("test.data.xml")
31 self.assertEqual(len(includes), 1)
32 self.assertEqual(includes[0], f"{scriptsdir}/test.schema.xml")
33

◆ test03_CanAddIncludes()

test_configuration.Configuration.test03_CanAddIncludes ( self)

Definition at line 34 of file test_configuration.py.

34 def test03_CanAddIncludes(self):
35 db = conffwk.Configuration("oksconflibs:test.data.xml")
36 db.add_include(f'{scriptsdir}/core.schema.xml')
37 includes = db.get_includes("test.data.xml")
38 print(includes)
39 self.assertEqual(len(includes), 2)
40 db.commit()
41 includes = db.get_includes("test.data.xml")
42 self.assertEqual(len(includes), 2)
43

◆ test04_CanRemoveIncludes()

test_configuration.Configuration.test04_CanRemoveIncludes ( self)

Definition at line 44 of file test_configuration.py.

44 def test04_CanRemoveIncludes(self):
45 db = conffwk.Configuration("oksconflibs:test.data.xml")
46 includes = db.get_includes()
47 self.assertEqual(len(includes), 2)
48 db.remove_include(includes[1])
49 db.commit()
50 includes = db.get_includes()
51 self.assertEqual(len(includes), 1)
52

◆ test05_CanCreateObject()

test_configuration.Configuration.test05_CanCreateObject ( self)

Definition at line 53 of file test_configuration.py.

53 def test05_CanCreateObject(self):
54 db = conffwk.Configuration("oksconflibs:test.data.xml")
55 for i in range(10):
56 db.create_obj("Dummy", "TestDummy-%d" % i)
57 db.commit()
58

◆ test05a_CanCreateObjectFromOtherObject()

test_configuration.Configuration.test05a_CanCreateObjectFromOtherObject ( self)

Definition at line 59 of file test_configuration.py.

59 def test05a_CanCreateObjectFromOtherObject(self):
60 db = conffwk.Configuration("oksconflibs:test.data.xml")
61 master = db.create_obj("Dummy", "MasterDummy")
62 for i in range(100, 110):
63 db.create_obj("Dummy", "TestDummy-%d" % i)
64 db.commit()
65

◆ test06_CanTestForObjects()

test_configuration.Configuration.test06_CanTestForObjects ( self)

Definition at line 66 of file test_configuration.py.

66 def test06_CanTestForObjects(self):
67 db = conffwk.Configuration("oksconflibs:test.data.xml")
68 for i in range(10):
69 self.assertTrue(db.test_object("Dummy", "TestDummy-%d" % i, 0, []))
70 for i in range(1000, 1010):
71 self.assertTrue(not db.test_object("Dummy", "TestDummy-%d" % i, 0, []))
72

◆ test07_DetectsExistingObjects()

test_configuration.Configuration.test07_DetectsExistingObjects ( self)

Definition at line 73 of file test_configuration.py.

73 def test07_DetectsExistingObjects(self):
74 db = conffwk.Configuration("oksconflibs:test.data.xml")
75 self.assertRaises(RuntimeError, db.create_obj, "Dummy", "TestDummy-3")
76

◆ test08_CanGetObject()

test_configuration.Configuration.test08_CanGetObject ( self)

Definition at line 77 of file test_configuration.py.

77 def test08_CanGetObject(self):
78 db = conffwk.Configuration("oksconflibs:test.data.xml")
79 obj = db.get_obj("Dummy", "TestDummy-4")
80

◆ test08a_CanGetObjects()

test_configuration.Configuration.test08a_CanGetObjects ( self)

Definition at line 81 of file test_configuration.py.

81 def test08a_CanGetObjects(self):
82 db = conffwk.Configuration("oksconflibs:test.data.xml")
83 objs = db.get_objs("Dummy")
84 self.assertEqual(len(objs), 21)
85

◆ test09_DoesNotCrashIfNonExisting()

test_configuration.Configuration.test09_DoesNotCrashIfNonExisting ( self)

Definition at line 86 of file test_configuration.py.

86 def test09_DoesNotCrashIfNonExisting(self):
87 db = conffwk.Configuration("oksconflibs:test.data.xml")
88 self.assertRaises(RuntimeError, db.get_obj, "Dummy", "TestDummy-44")
89

◆ test10_CanRemoveObject()

test_configuration.Configuration.test10_CanRemoveObject ( self)

Definition at line 90 of file test_configuration.py.

90 def test10_CanRemoveObject(self):
91 db = conffwk.Configuration("oksconflibs:test.data.xml")
92 obj = db.get_obj("Dummy", "TestDummy-1")
93 db.destroy_obj(obj)
94 db.commit()
95 self.assertRaises(RuntimeError, db.get_obj, "Dummy", "TestDummy-1")
96

◆ test11_CanCycleThroughStates()

test_configuration.Configuration.test11_CanCycleThroughStates ( self)

Definition at line 97 of file test_configuration.py.

97 def test11_CanCycleThroughStates(self):
98 db = conffwk.Configuration("oksconflibs:test.data.xml")
99 self.assertTrue(db.loaded())
100 db.unload()
101 self.assertTrue(not db.loaded())
102 db.load("test.data.xml")
103 self.assertTrue(db.loaded())
104 db.unload()
105 self.assertTrue(not db.loaded())
106

◆ test12_CanStuffThousands()

test_configuration.Configuration.test12_CanStuffThousands ( self)

Definition at line 107 of file test_configuration.py.

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

◆ test13_CanCommitDeepRelations()

test_configuration.Configuration.test13_CanCommitDeepRelations ( self)

Definition at line 115 of file test_configuration.py.

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

◆ test14_CanRetrieveDeepRelations()

test_configuration.Configuration.test14_CanRetrieveDeepRelations ( self)

Definition at line 133 of file test_configuration.py.

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

◆ test15_CommitWithComment()

test_configuration.Configuration.test15_CommitWithComment ( self)

Definition at line 149 of file test_configuration.py.

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

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