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

Source Code for Module EDTestCaseEDShare

 1  # coding: utf8 
 2  # 
 3  #    Project: The EDNA Kernel 
 4  #             http://www.edna-site.org 
 5  # 
 6  #    File: "$Id: EDTestCaseParallelExecute.py 2548 2010-12-01 09:14:01Z kieffer $" 
 7  # 
 8  #    Copyright (C) 2011-2011 European Synchrotron Radiation Facility 
 9  #                            Grenoble, France 
10  # 
11  #    Principal authors: Jérôme Kieffer (Jerome.Kieffer@esrf.eu) 
12  #                         
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__ = ["Jérôme Kieffer", "Olof Svensson"] 
30  __contact__ = "Jerome.Kieffer@esrf.eu" 
31  __license__ = "LGPLv3+" 
32  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
33  __date__ = "20110722" 
34   
35  """Test cases for testing EDShare""" 
36   
37  import  time, tempfile, os 
38  from EDVerbose                           import EDVerbose 
39  from EDTestCase                          import EDTestCase 
40  from EDAssert                            import EDAssert 
41  from EDShare                             import EDShare 
42  from EDFactoryPluginStatic               import EDFactoryPluginStatic 
43  from EDUtilsPath                         import EDUtilsPath 
44  EDFactoryPluginStatic.loadModule("EDInstallNumpyv1_3") 
45  EDFactoryPluginStatic.loadModule("EDInstallH5Pyv1_3_0") 
46  if "USER" not in os.environ: 
47      os.environ["USER"] = "ednatester" 
48   
49   
50   
51 -class EDTestCaseEDShare(EDTestCase):
52 """ 53 Unit test for EDNA-share for sharing large objects between plugins 54 """ 55
56 - def unitTestInitialState(self):
57 """ 58 Check the initialization of the share: 59 """ 60 EDAssert.equal(False, EDShare.isInitialized(), "Check that EDShare is uninitialized") 61 strEdnaUserTempFolder = EDUtilsPath.getEdnaUserTempFolder() 62 EDShare.initialize(strEdnaUserTempFolder) 63 EDShare["test1"] = range(10) 64 EDVerbose.screen("Backend used is %s" % EDShare.backend) 65 EDAssert.equal(1, len(EDShare.items())) 66 EDAssert.equal(True, "test1" in EDShare, "list is actually present") 67 for i, j in zip(range(10), EDShare["test1"]): 68 EDAssert.equal(i, j, "elements are the same") 69 EDShare.close() 70 EDShare.initialize(strEdnaUserTempFolder) 71 EDAssert.equal(True, "test1" in EDShare, "list is still present") 72 for i, j in zip(range(10), EDShare["test1"]): 73 EDAssert.equal(i, j, "elements are still the same") 74 filename = EDShare.filename 75 EDShare.close(remove=True) 76 EDAssert.equal(False, os.path.isfile(filename), "dump-file has been removed")
77 78
79 - def process(self):
81 82 83 if __name__ == '__main__': 84 85 edTestCase = EDTestCaseEDShare("EDTestCaseEDShare") 86 edTestCase.execute() 87