/[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 1756 by bh, Fri Sep 26 14:03:51 2003 UTC revision 1787 by bh, Wed Oct 8 10:39:18 2003 UTC
# Line 253  class TestProjFile(unittest.TestCase, su Line 253  class TestProjFile(unittest.TestCase, su
253          file.write(input)          file.write(input)
254          file.close()          file.close()
255    
256          pf = resource.read_proj_file(filename)          pf, warnings = resource.read_proj_file(filename)
257            self.assertEquals(warnings, [])
258    
259          eq = self.assertEquals          eq = self.assertEquals
260    
# Line 264  class TestProjFile(unittest.TestCase, su Line 265  class TestProjFile(unittest.TestCase, su
265              for param in proj.GetAllParameters():              for param in proj.GetAllParameters():
266                  self.assert_(param in d[1])                  self.assert_(param in d[1])
267    
268        def test_get_system_proj_file(self):
269            """Test resource.get_system_proj_file()
270    
271            This is primarily to test whether the system proj file contains
272            invalid projection paramers and whether the proj file is not
273            empty
274            """
275            projfile, warnings = resource.get_system_proj_file()
276            self.assertEquals(warnings, [])
277            self.assert_(len(projfile.GetProjections()) > 0)
278    
279    
280    class TestProjFileWithInvalidParameters(unittest.TestCase,
281                                            support.FileLoadTestCase):
282    
283        file_extension = ".proj"
284        file_contents = '''\
285    <?xml version="1.0" encoding="UTF-8"?>
286    <!DOCTYPE projectionlist SYSTEM "projfile.dtd">
287    <projectionlist>
288        <projection name="Universal Transverse Mercator">
289            <parameter value="proj=utm"/>
290            <parameter value="ellps=clrk66"/>
291            <!-- an invalid zone number to trigger the parameter checking
292                 in the proj library -->
293            <parameter value="zone=1000"/>
294        </projection>
295        <projection name="Transverse Mercator">
296            <parameter value="proj=tmerc"/>
297            <parameter value="ellps=clrk66"/>
298            <parameter value="lat_0=90w"/>
299            <parameter value="lon_0=90w"/>
300            <parameter value="k=1"/>
301        </projection>
302    </projectionlist>
303    '''
304    
305        def setUp(self):
306            support.FileLoadTestCase.setUp(self)
307    
308        def test(self):
309            """Test reading a proj file with invalid parameters"""
310            projfile, warnings = resource.read_proj_file(self.filename())
311            projs = projfile.GetProjections()
312            self.assertEquals(len(projs), 1)
313            params = projs[0].GetAllParameters()[:]
314            params.sort()
315            self.assertEquals(params, ['ellps=clrk66', 'k=1', 'lat_0=90w',
316                                       'lon_0=90w', 'proj=tmerc'])
317            self.assertEquals(warnings,
318                           ['Error in projection "Universal Transverse Mercator":'
319                            ' invalid UTM zone number'])
320    
321    
322    
323  if __name__ == "__main__":  if __name__ == "__main__":
324      unittest.main()      unittest.main()

Legend:
Removed from v.1756  
changed lines
  Added in v.1787

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26