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

Source Code for Module EDTestCasePluginUnit

 1  #coding: utf8 
 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  #                       Jérôme Kieffer (kieffer@esrf.fr)  
13  # 
14  #    This program is free software: you can redistribute it and/or modify 
15  #    it under the terms of the GNU Lesser General Public License as published 
16  #    by the Free Software Foundation, either version 3 of the License, or 
17  #    (at your option) any later version. 
18  # 
19  #    This program is distributed in the hope that it will be useful, 
20  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
21  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
22  #    GNU Lesser General Public License for more details. 
23  # 
24  #    You should have received a copy of the GNU General Public License 
25  #    and the GNU Lesser General Public License  along with this program.   
26  #    If not, see <http://www.gnu.org/licenses/>. 
27  # 
28   
29  __authors__ = [ "Olof Svensson", "Jérôme Kieffer" ] 
30  __contact__ = "svensson@esrf.fr" 
31  __license__ = "LGPLv3+" 
32  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
33  __date__ = "20120216" 
34   
35  import os, glob, shutil 
36   
37  from EDVerbose import EDVerbose 
38  from EDConfiguration import EDConfiguration 
39  from EDTestCasePlugin import EDTestCasePlugin 
40  from EDUtilsParallel    import EDUtilsParallel 
41   
42 -class EDTestCasePluginUnit(EDTestCasePlugin):
43 """ 44 This is the main class for all Plugin Unit tests 45 """ 46
47 - def __init__(self, _strPluginName, _strPluginDir=None, _strTestName=None):
48 """ 49 Initialize the Plugin Unit test 50 """ 51 EDTestCasePlugin.__init__(self, _strPluginName, _strPluginDir, _strTestName) 52 self.__edPlugin = None 53 # To track dead locks 54 EDUtilsParallel.initializeNbThread(1)
55 56
57 - def preProcess(self):
58 """ 59 Creates the main plugin instance 60 """ 61 self.__edPlugin = self.createPlugin()
62 63
64 - def getPlugin(self):
65 """ 66 Returns the main plugin instance 67 """ 68 return self.__edPlugin
69 70
71 - def getPluginConfiguration(self, _strConfigurationFileName):
72 """ 73 Returns the plugin configuration from a configuration file 74 """ 75 xsPluginItem = None 76 edConfiguration = EDConfiguration(_strConfigurationFileName) 77 if(edConfiguration != None): 78 xsPluginItem = edConfiguration.getXSConfigurationItem(self.getPluginName()) 79 if(xsPluginItem == None): 80 EDVerbose.warning("EDTestCasePluginUnit.getPluginConfiguration: Could not get configuration plugin item for: " + self.getPluginName()) 81 else: 82 EDVerbose.warning("EDTestCasePluginUnit.getPluginConfiguration: Could not load Configuration: " + _strConfigurationFileName) 83 return xsPluginItem
84 85
86 - def cleanUp(self, _edPlugin):
87 """ 88 Cleans up some empty directories 89 (mainly working directories that were created automatically, but not filled as Unit tests do not execute the plugin) 90 """ 91 workingDirectory = _edPlugin.getWorkingDirectory() 92 if(workingDirectory is not None): 93 fileList = glob.glob(os.path.join(workingDirectory, "*")) 94 if(len(fileList) == 0): 95 EDVerbose.DEBUG("Deleting " + workingDirectory + " ...") 96 shutil.rmtree(workingDirectory) 97 EDUtilsParallel.semaphoreNbThreadsRelease()
98