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

Source Code for Module EDTestCaseEDUtilsPath

 1  # coding: utf8 
 2  # 
 3  #    Project: The EDNA Kernel 
 4  #             http://www.edna-site.org 
 5  # 
 6  #    Copyright (C) 2008-2012 European Synchrotron Radiation Facility 
 7  #                            Grenoble, France 
 8  # 
 9  #    Principal authors: Olof Svensson (svensson@esrf.fr) 
10  # 
11  #    This program is free software: you can redistribute it and/or modify 
12  #    it under the terms of the GNU Lesser General Public License as published 
13  #    by the Free Software Foundation, either version 3 of the License, or 
14  #    (at your option) any later version. 
15  # 
16  #    This program is distributed in the hope that it will be useful, 
17  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
18  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
19  #    GNU Lesser General Public License for more details. 
20  # 
21  #    You should have received a copy of the GNU General Public License 
22  #    and the GNU Lesser General Public License  along with this program.   
23  #    If not, see <http://www.gnu.org/licenses/>. 
24  # 
25   
26  __authors__ = [ "Olof Svensson" ] 
27  __contact__ = "svensson@esrf.fr" 
28  __license__ = "LGPLv3+" 
29  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
30   
31  """ 
32  This is the test case for the EDUtilsFile static class. 
33  """ 
34   
35   
36  import os, tempfile 
37   
38  from EDTestCase     import EDTestCase 
39  from EDVerbose      import EDVerbose 
40  from EDAssert       import EDAssert 
41  from EDUtilsFile    import EDUtilsFile 
42  from EDUtilsPath    import EDUtilsPath 
43   
44 -class EDTestCaseEDUtilsPath(EDTestCase):
45 46
47 - def __init__(self, _strTestName=None):
48 EDTestCase.__init__(self, "EDTestCaseEDUtilsPath")
49 50
52 # Test that we can access the user temp folder 53 strUserTempFolder = EDUtilsPath.getEdnaUserTempFolder() 54 EDAssert.equal(True, os.path.exists(strUserTempFolder), "Checking that user temp folder exists") 55 # Test if we can write to the temp folder 56 strTest = "This is a test string." 57 strPathTestFile = os.path.join(strUserTempFolder, "EDTestCaseEDUtilsPath_testFile.txt") 58 EDUtilsFile.writeFile(strPathTestFile, strTest) 59 EDAssert.equal(True, os.path.exists(strPathTestFile), "Checking that new temp file exists") 60 # Delete the test file 61 os.remove(strPathTestFile)
62 63 64 65
66 - def process(self):
68 69 70 if __name__ == '__main__': 71 72 edTestCaseEDUtilsPath = EDTestCaseEDUtilsPath("EDTestCaseEDUtilsPath") 73 edTestCaseEDUtilsPath.execute() 74