Tests if we can manipulate ConfigurationWrap objects as expected.
Definition at line 12 of file test_configuration.py.
◆ test01_CanCreateDB()
test_configuration.Configuration.test01_CanCreateDB |
( |
| self | ) |
|
Definition at line 15 of file test_configuration.py.
15 def test01_CanCreateDB(self):
17 db.create_db("test.data.xml", [f'{scriptsdir}/test.schema.xml'])
18 db.commit()
19
◆ test01a_DoesNotCrashIfDBNotThere()
test_configuration.Configuration.test01a_DoesNotCrashIfDBNotThere |
( |
| self | ) |
|
◆ test02_CanReopenDB()
test_configuration.Configuration.test02_CanReopenDB |
( |
| self | ) |
|
Definition at line 23 of file test_configuration.py.
23 def test02_CanReopenDB(self):
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):
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):
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):
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):
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):
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):
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):
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):
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):
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):
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):
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
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
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
130 import sys
131 sys.setrecursionlimit(10000)
132
133 depth = 10000
135
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']
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):
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: