3 """Define TileFolders class to keep and return Tile folders"""
6 """Keep Tile folders taking into account whether it is online/offline and MC/Data"""
9 """Initialize taking into account whether it is online/offline and MC/Data"""
14 def add(self, folder, db):
15 """Add and return Tile folder using given db Tile schema"""
16 self.
_folders.
append((folder +
'<key>' + folder +
'</key>', db,
'CondAttrListCollection'))
20 """Add and return Tile folder, using folder (online) for real data, folderMC (offline) for MC"""
21 actualFolder, db = (folderMC,
'TILE_OFL')
if self.
_isMC else (folder,
'TILE')
22 return self.
add(actualFolder, db)
25 """Add and return Tile folder, using onlineFolder online, oflineFolder offline"""
26 actualFolder, db = (onlineFolder,
'TILE')
if self.
_isOnlineAndNotMC else (oflineFolder,
'TILE_OFL')
27 return self.
add(actualFolder, db)
30 """Return Tile folders as list of (folder, DB, 'CondAttrListCollection')"""
38 folders =
TileFolders(isMC =
False, isOnline =
False)
39 self.assertEqual(folders.get(), [],
'Initial folders are not empty')
41 self.assertEqual(folders.add(
'TEST',
'DB'),
'TEST',
'Wrong folder is added')
42 self.assertTrue((
'TEST<key>TEST</key>',
'DB',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
44 self.assertEqual(folders.addSplitOnline(
'ONL',
'OFL'),
'OFL',
'Wrong folder is added')
45 self.assertTrue((
'OFL<key>OFL</key>',
'TILE_OFL',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
47 self.assertEqual(folders.addSplitMC(
'DATA',
'MC'),
'DATA',
'Wrong folder is added')
48 self.assertTrue((
'DATA<key>DATA</key>',
'TILE',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
50 self.assertEqual(len(folders.get()), 3,
'Number of added folders is wrong')
54 folders =
TileFolders(isMC =
True, isOnline =
False)
55 self.assertEqual(folders.get(), [],
'Initial folders are not empty')
57 self.assertEqual(folders.add(
'TEST',
'DB'),
'TEST',
'Wrong folder is added')
58 self.assertTrue((
'TEST<key>TEST</key>',
'DB',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
60 self.assertEqual(folders.addSplitOnline(
'ONL',
'OFL'),
'OFL',
'Wrong folder is added')
61 self.assertTrue((
'OFL<key>OFL</key>',
'TILE_OFL',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
63 self.assertEqual(folders.addSplitMC(
'DATA',
'MC'),
'MC',
'Wrong folder is added')
64 self.assertTrue((
'MC<key>MC</key>',
'TILE_OFL',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
66 self.assertEqual(len(folders.get()), 3,
'Number of added folders is wrong')
70 folders =
TileFolders(isMC =
False, isOnline =
True)
71 self.assertEqual(folders.get(), [],
'Initial folders are not empty')
73 self.assertEqual(folders.add(
'TEST',
'DB'),
'TEST',
'Wrong folder is added')
74 self.assertTrue((
'TEST<key>TEST</key>',
'DB',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
76 self.assertEqual(folders.addSplitOnline(
'ONL',
'OFL'),
'ONL',
'Wrong folder is added')
77 self.assertTrue((
'ONL<key>ONL</key>',
'TILE',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
79 self.assertEqual(folders.addSplitMC(
'DATA',
'MC'),
'DATA',
'Wrong folder is added')
80 self.assertTrue((
'DATA<key>DATA</key>',
'TILE',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
82 self.assertEqual(len(folders.get()), 3,
'Number of added folders is wrong')
87 self.assertEqual(folders.get(), [],
'Initial folders are not empty')
89 self.assertEqual(folders.add(
'TEST',
'DB'),
'TEST',
'Wrong folder is added')
90 self.assertTrue((
'TEST<key>TEST</key>',
'DB',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
92 self.assertEqual(folders.addSplitOnline(
'ONL',
'OFL'),
'OFL',
'Wrong folder is added')
93 self.assertTrue((
'OFL<key>OFL</key>',
'TILE_OFL',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
95 self.assertEqual(folders.addSplitMC(
'DATA',
'MC'),
'MC',
'Wrong folder is added')
96 self.assertTrue((
'MC<key>MC</key>',
'TILE_OFL',
'CondAttrListCollection')
in folders.get(),
'No correct folder')
98 self.assertEqual(len(folders.get()), 3,
'Number of added folders is wrong')
102 if __name__ ==
"__main__":