/[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 1827 by bh, Tue Oct 14 16:04:35 2003 UTC revision 1888 by jan, Thu Oct 30 09:31:56 2003 UTC
# Line 80  class TestProjection(unittest.TestCase, Line 80  class TestProjection(unittest.TestCase,
80          self.assertEquals(proj.GetParameter("south"), "south")          self.assertEquals(proj.GetParameter("south"), "south")
81    
82      def test_get_projection_units_geo(self):      def test_get_projection_units_geo(self):
83          """Test Projection.GetProjectedUnits() for geographic projection"""          """Test Projection.GetProjectedUnits() for geographic projection.
84            Test for the alias 'longlat' as well.
85            """
86          proj = Projection(["proj=latlong", "to_meter=0.017453292519943295",          proj = Projection(["proj=latlong", "to_meter=0.017453292519943295",
87                             "ellps=clrk66"])                             "ellps=clrk66"])
88          self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES)          self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES)
89            proj = Projection(["proj=longlat", "to_meter=0.017453292519943295",
90                               "ellps=clrk66"])
91            self.assertEquals(proj.GetProjectedUnits(), PROJ_UNITS_DEGREES)
92    
93      def test_get_projection_units_normal(self):      def test_get_projection_units_normal(self):
94          """Test Projection.GetProjectedUnits() for normal projection"""          """Test Projection.GetProjectedUnits() for normal projection"""
# Line 133  class TestProjFileSimple: Line 138  class TestProjFileSimple:
138    
139  class TestProjFile(unittest.TestCase, support.SubscriberMixin):  class TestProjFile(unittest.TestCase, support.SubscriberMixin):
140    
141      """Test cases for reading and writing projection files.      """Test cases for ProjFile objects"""
     """  
142    
143      def setUp(self):      def setUp(self):
144          self.clear_messages()          self.clear_messages()
# Line 208  class ProjFileTest(unittest.TestCase, su Line 212  class ProjFileTest(unittest.TestCase, su
212    
213  class ProjFileReadTests(ProjFileTest):  class ProjFileReadTests(ProjFileTest):
214    
215      """Test read ProjFile objects from files"""      """Test read ProjFile objects from files
216    
217        The files only cover error handling and the system projection file.
218        """
219    
220      def test_read_non_existing_file(self):      def test_read_non_existing_file(self):
221          """Test read_proj_file with non-existing file"""          """Test read_proj_file with non-existing file"""
# Line 247  class ProjFileReadTests(ProjFileTest): Line 254  class ProjFileReadTests(ProjFileTest):
254          self.assertEquals(warnings, [])          self.assertEquals(warnings, [])
255          self.assert_(len(projfile.GetProjections()) > 0)          self.assert_(len(projfile.GetProjections()) > 0)
256    
257            # see whether it got cached and we get the same projfile object
258            # when we read the file again
259            projfile2, warnings = resource.get_system_proj_file()
260            self.assert_(projfile is projfile2)
261    
262    
263  class WriteProjFileTests(ProjFileTest):  class WriteProjFileTests(ProjFileTest):
264    
# Line 315  class WriteProjFileTests(ProjFileTest): Line 327  class WriteProjFileTests(ProjFileTest):
327          self.doTestWrite(pf, file_contents)          self.doTestWrite(pf, file_contents)
328    
329    
330  class TestLoadingProjFile(support.FileLoadTestCase):  class ProjFileLoadTestCase(support.FileLoadTestCase):
331    
332        """Base class for the test cases that read specific test files"""
333    
334      file_extension = ".proj"      file_extension = ".proj"
335    
336        def tearDown(self):
337            """Clear the cache explicitly"""
338            resource.clear_proj_file_cache()
339    
340    
341    class TestLoadingProjFile(ProjFileLoadTestCase):
342    
343      file_contents = '''\      file_contents = '''\
344  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
345  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">
# Line 369  class TestLoadingProjFile(support.FileLo Line 391  class TestLoadingProjFile(support.FileLo
391                                 "proj=tmerc", "units=m",                                 "proj=tmerc", "units=m",
392                                 "x_0=400000.000", "y_0=0.000"])                                 "x_0=400000.000", "y_0=0.000"])
393    
394        def test_caching(self):
395            # test whether the projfile cache works
396            projfile, warnings = resource.read_proj_file(self.filename())
397            projfile2, warnings = resource.read_proj_file(self.filename())
398    
399  class TestLoadingProjFileWithEmptyProjectionlist(support.FileLoadTestCase):          # Both projfiles should be the same object
400            self.assert_(projfile2 is projfile)
401    
402            # If we clear the cache we should get a new one.
403            resource.clear_proj_file_cache()
404            projfile3, warnings = resource.read_proj_file(self.filename())
405            self.assert_(projfile3 is not projfile)
406    
407    
408    class TestLoadingProjFileWithEmptyProjectionlist(ProjFileLoadTestCase):
409    
     file_extension = ".proj"  
410      file_contents = '''\      file_contents = '''\
411  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
412  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">
# Line 389  class TestLoadingProjFileWithEmptyProjec Line 423  class TestLoadingProjFileWithEmptyProjec
423          self.assertEquals(len(projfile.GetProjections()), 0)          self.assertEquals(len(projfile.GetProjections()), 0)
424    
425    
426  class TestProjFileWithInvalidParameters(unittest.TestCase,  class TestProjFileWithInvalidParameters(ProjFileLoadTestCase):
                                         support.FileLoadTestCase):  
427    
     file_extension = ".proj"  
428      file_contents = '''\      file_contents = '''\
429  <?xml version="1.0" encoding="UTF-8"?>  <?xml version="1.0" encoding="UTF-8"?>
430  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">  <!DOCTYPE projectionlist SYSTEM "projfile.dtd">

Legend:
Removed from v.1827  
changed lines
  Added in v.1888

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26