/[thuban]/branches/WIP-pyshapelib-bramz/test/test_proj.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/test/test_proj.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 761 by jonathan, Tue Apr 29 09:02:15 2003 UTC revision 1684 by bh, Thu Aug 28 18:55:01 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2002 by Intevation GmbH  # Copyright (c) 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 13  __version__ = "$Revision$" Line 13  __version__ = "$Revision$"
13  # $Source$  # $Source$
14  # $Id$  # $Id$
15    
 from Thuban import _  
   
16  import unittest  import unittest
17  import os  import os
18    
19  import support  import support
20  support.initthuban()  support.initthuban()
21    
22    from Thuban import _
23  from Thuban.Model.proj import Projection, ProjFile  from Thuban.Model.proj import Projection, ProjFile
24    
25  import Thuban.Model.resource as resource  import Thuban.Model.resource as resource
26    
27  from test_save import sax_eventlist  from xmlsupport import sax_eventlist
28    
29  from xml.sax import SAXParseException  from xml.sax import SAXParseException
30    
# Line 191  class TestProjFile(unittest.TestCase, su Line 190  class TestProjFile(unittest.TestCase, su
190          self.assertRaises(ValueError, projFile.Replace, proj0, proj2)          self.assertRaises(ValueError, projFile.Replace, proj0, proj2)
191    
192      def testRead(self):      def testRead(self):
193          """Test ReadProjFile"""          """Test read_proj_file"""
194    
195          self.doTestRead(sample_projfile_data, sample_projfile)          self.doTestRead(sample_projfile_data, sample_projfile)
196          self.doTestRead(sample_projfile_data2, sample_projfile2)          self.doTestRead(sample_projfile_data2, sample_projfile2)
# Line 200  class TestProjFile(unittest.TestCase, su Line 199  class TestProjFile(unittest.TestCase, su
199          # file doesn't exist          # file doesn't exist
200          #          #
201          self.assertRaises(IOError,          self.assertRaises(IOError,
202              resource.ReadProjFile, self.temp_file_name("nonexistent.proj"))              resource.read_proj_file, self.temp_file_name("nonexistent.proj"))
203    
204          #          #
205          # file isn't readable          # file isn't readable
# Line 209  class TestProjFile(unittest.TestCase, su Line 208  class TestProjFile(unittest.TestCase, su
208          file = open(filename, "w")          file = open(filename, "w")
209          file.close()          file.close()
210          os.chmod(filename, 0200) # write-only          os.chmod(filename, 0200) # write-only
211          self.assertRaises(IOError, resource.ReadProjFile, filename)          self.assertRaises(IOError, resource.read_proj_file, filename)
212          os.chmod(filename, 0600) # read/write so we reuse the file          os.chmod(filename, 0600) # read/write so we reuse the file
213    
214          #          #
# Line 219  class TestProjFile(unittest.TestCase, su Line 218  class TestProjFile(unittest.TestCase, su
218          file = open(filename, "w")          file = open(filename, "w")
219          file.close()          file.close()
220    
221          self.assertRaises(SAXParseException, resource.ReadProjFile, filename)          self.assertRaises(SAXParseException, resource.read_proj_file, filename)
222    
223      def testWrite(self):      def testWrite(self):
224          """Test WriteProjFile"""          """Test write_proj_file"""
225    
226          self.doTestWrite(sample_projfile_data, sample_projfile)          self.doTestWrite(sample_projfile_data, sample_projfile)
227          self.doTestWrite(sample_projfile_data2, sample_projfile2)          self.doTestWrite(sample_projfile_data2, sample_projfile2)
# Line 235  class TestProjFile(unittest.TestCase, su Line 234  class TestProjFile(unittest.TestCase, su
234          for proj in data:          for proj in data:
235              pf.Add(Projection(proj[1], proj[0]))              pf.Add(Projection(proj[1], proj[0]))
236    
237          resource.WriteProjFile(pf)          resource.write_proj_file(pf)
238    
239          file = open(filename)          file = open(filename)
240          written_contents = file.read()          written_contents = file.read()
# Line 249  class TestProjFile(unittest.TestCase, su Line 248  class TestProjFile(unittest.TestCase, su
248          file.write(input)          file.write(input)
249          file.close()          file.close()
250    
251          pf = resource.ReadProjFile(filename)          pf = resource.read_proj_file(filename)
252    
253          eq = self.assertEquals          eq = self.assertEquals
254    

Legend:
Removed from v.761  
changed lines
  Added in v.1684

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26