Module EDTestCaseEDUtilsTable
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 __authors__ = [ "Marie-Francoise Incardona", "Olof Svensson" ]
29 __contact__ = "svensson@esrf.fr"
30 __license__ = "LGPLv3+"
31 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
32
33 import os
34
35 from EDVerbose import EDVerbose
36 from XSDataDnaTables import dna_tables
37
38 from EDUtilsTest import EDUtilsTest
39 from EDUtilsFile import EDUtilsFile
40 from EDUtilsTable import EDUtilsTable
41 from EDAssert import EDAssert
42 from EDTestCase import EDTestCase
43
44
46
48 EDTestCase.__init__(self, "EDTestCaseEDUtilsTable")
49 self.__edConfiguration = None
50 strKernelDataHome = EDUtilsTest.getPluginTestDataDirectory(self.getClassName())
51 strDataDir = "EDUtilsTable"
52 self.__strDataPath = os.path.join(strKernelDataHome, strDataDir)
53 self.__strFileName = "EDPluginBestv01_dnaTables.xml"
54 self.__strFilePath = os.path.join(self.__strDataPath, self.__strFileName)
55 self.__strFileName2 = "EDPluginBestv01_dnaTables2.xml"
56 self.__strFilePath2 = os.path.join(self.__strDataPath, self.__strFileName2)
57
58
60 xsItem = None
61 xsItem2 = None
62 strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath)
63 xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
64 xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "input")
65 xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_task")
66 for xsList in xsLists:
67 xsItem = EDUtilsTable.getItemFromList(xsList, "task")
68 xsItem2 = EDUtilsTable.getItemFromList(xsList, "tata")
69 EDAssert.equal("optimize", xsItem.getValueOf_())
70
71 EDAssert.equal(None, xsItem2)
72
73 xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_tata")
74 EDAssert.equal([], xsLists)
75
76 xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "toto")
77 EDAssert.equal(None, xsTable)
78
79 EDVerbose.DEBUG("Test done...")
80
81
83 xsItem = None
84 xsItem2 = None
85 strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath2)
86 xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
87 listTable = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "data_collection_strategy")
88
89 EDAssert.equal(2, len(listTable))
90
91 bFoundPlan1 = False
92 bFoundPlan2 = False
93
94 for xsTable in listTable:
95 xsItem = None
96 xsLists = EDUtilsTable.getListsFromTable(xsTable, "summary")
97 for xsList in xsLists:
98 xsItem = EDUtilsTable.getItemFromList(xsList, "resolution_reasoning")
99
100 if(xsItem.getValueOf_() == "Low-resolution pass, no overloads"):
101 bFoundPlan1 = True
102 if(xsItem.getValueOf_() == "Resolution limit is set by the initial image resolution"):
103 bFoundPlan2 = True
104
105 EDAssert.equal(True, bFoundPlan1)
106 EDAssert.equal(True, bFoundPlan2)
107
108
109
113
114
115
116
117 if __name__ == '__main__':
118
119 edTestCaseEDUtilsTable = EDTestCaseEDUtilsTable("TestCase EDTestCaseEDUtilsTable")
120 edTestCaseEDUtilsTable.execute()
121