/[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 752 by jonathan, Fri Apr 25 14:23:34 2003 UTC revision 761 by jonathan, Tue Apr 29 09:02:15 2003 UTC
# Line 13  __version__ = "$Revision$" Line 13  __version__ = "$Revision$"
13  # $Source$  # $Source$
14  # $Id$  # $Id$
15    
16    from Thuban import _
17    
18  import unittest  import unittest
19  import os  import os
20    
# Line 35  class TestProjection(unittest.TestCase, Line 37  class TestProjection(unittest.TestCase,
37    
38      def test(self):      def test(self):
39          """Test Projection"""          """Test Projection"""
40          proj = Projection(["zone=26", "proj=utm", "ellps=clrk66"])          params = ["zone=26", "proj=utm", "ellps=clrk66"]
41          self.assertEquals(proj.params, ["zone=26", "proj=utm", "ellps=clrk66"])          proj = Projection(params)
42            self.assertEquals(proj.params, params)
43    
44          # It's not clear whether this value is really the correct one          # It's not clear whether this value is really the correct one
45          # but a test failure here probably still means a bug somewhere          # but a test failure here probably still means a bug somewhere
# Line 51  class TestProjection(unittest.TestCase, Line 54  class TestProjection(unittest.TestCase,
54                                    3875381.8535437919, 252962.10480170773),                                    3875381.8535437919, 252962.10480170773),
55                                   epsilon = 1e-5)                                   epsilon = 1e-5)
56    
57            # GetName()
58            self.assertEquals(proj.GetName(), _("Unknown"))
59    
60            # GetParameter()
61          self.assertEquals(proj.GetParameter("zone"), "26")          self.assertEquals(proj.GetParameter("zone"), "26")
62          self.assertEquals(proj.GetParameter("proj"), "utm")          self.assertEquals(proj.GetParameter("proj"), "utm")
63          self.assertEquals(proj.GetParameter("ellps"), "clrk66")          self.assertEquals(proj.GetParameter("ellps"), "clrk66")
64          self.assertEquals(proj.GetParameter("hallo"), "")          self.assertEquals(proj.GetParameter("hallo"), "")
65    
66            # GetAllParameters()
67            self.assertEquals(proj.GetAllParameters(), params)
68    
69            # GetName()
70            proj = Projection(params, "MyName")
71            self.assertEquals(proj.GetName(), "MyName")
72    
73    
74  sample_projfile = '''\  sample_projfile = '''\
75  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
# Line 123  class TestProjFile(unittest.TestCase, su Line 137  class TestProjFile(unittest.TestCase, su
137    
138          eq = self.assertEquals          eq = self.assertEquals
139    
140    
141          #          #
142          # __init__()          # __init__()
143          # GetFilename()          # GetFilename()
# Line 149  class TestProjFile(unittest.TestCase, su Line 164  class TestProjFile(unittest.TestCase, su
164          eq(len(projFile.GetProjections()), 0)          eq(len(projFile.GetProjections()), 0)
165    
166          # try to remove something that doesn't exist          # try to remove something that doesn't exist
167            self.assertRaises(ValueError, projFile.Remove, None)
168          self.assertRaises(ValueError, projFile.Remove, proj0)          self.assertRaises(ValueError, projFile.Remove, proj0)
169    
170          projFile.Add(proj0)          projFile.Add(proj0)
# Line 162  class TestProjFile(unittest.TestCase, su Line 178  class TestProjFile(unittest.TestCase, su
178          eq(projs[1], proj1)          eq(projs[1], proj1)
179          eq(projs[2], proj2)          eq(projs[2], proj2)
180    
181          #          projFile.Remove(proj2)
182          # SetAllParameters()          projFile.Remove(proj1)
183          # SetName()  
184          # SetProjection()          # Replace()
185          #          projFile.Replace(proj0, proj1)
186          params = ["proj=utm", "ellps=clrk66", "zone=13"]          projs = projFile.GetProjections()
187          proj0.SetAllParameters(params)          eq(projs[0], proj1)
188          eq(proj0.GetAllParameters(), params)  
189                    # replace a non-existent projection
190          proj2.SetName("something")          self.assertRaises(ValueError, projFile.Replace, None, proj2)
191          proj0.SetProjection(proj2)          self.assertRaises(ValueError, projFile.Replace, proj0, proj2)
         eq(proj0.GetName(), "something")  
         eq(proj0.GetAllParameters(), proj2.GetAllParameters())  
192    
193      def testRead(self):      def testRead(self):
194          """Test ReadProjFile"""          """Test ReadProjFile"""

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26