Module EDTestCaseEDUtilsTable
[hide private]
[frames] | no frames]

Source Code for Module EDTestCaseEDUtilsTable

  1  # 
  2  #    Project: The EDNA Kernel 
  3  #             http://www.edna-site.org 
  4  # 
  5  #    File: "$Id$" 
  6  # 
  7  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
  8  #                            Grenoble, France 
  9  # 
 10  #    Principal authors: Marie-Francoise Incardona (incardon@esrf.fr) 
 11  #                       Olof Svensson (svensson@esrf.fr)  
 12  # 
 13  #    This program is free software: you can redistribute it and/or modify 
 14  #    it under the terms of the GNU Lesser General Public License as published 
 15  #    by the Free Software Foundation, either version 3 of the License, or 
 16  #    (at your option) any later version. 
 17  # 
 18  #    This program is distributed in the hope that it will be useful, 
 19  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 20  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 21  #    GNU Lesser General Public License for more details. 
 22  # 
 23  #    You should have received a copy of the GNU General Public License 
 24  #    and the GNU Lesser General Public License  along with this program.   
 25  #    If not, see <http://www.gnu.org/licenses/>. 
 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   
45 -class EDTestCaseEDUtilsTable(EDTestCase):
46
47 - def __init__(self, _strTestName=None):
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
59 - def testTableListItem(self):
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
82 - def testListOfTables(self):
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
110 - def process(self):
113 114 115 116 117 if __name__ == '__main__': 118 119 edTestCaseEDUtilsTable = EDTestCaseEDUtilsTable("TestCase EDTestCaseEDUtilsTable") 120 edTestCaseEDUtilsTable.execute() 121