PageRenderTime 243ms CodeModel.GetById 121ms app.highlight 4ms RepoModel.GetById 116ms app.codeStats 0ms

/django/contrib/gis/gdal/tests/test_driver.py

https://code.google.com/p/mango-py/
Python | 40 lines | 31 code | 9 blank | 0 comment | 6 complexity | 24a1cc1bd4eb6e6a9f5362436d55ff39 MD5 | raw file
 1import os, os.path, unittest
 2from django.contrib.gis.gdal import Driver, OGRException
 3
 4valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN',
 5                 'Memory', 'CSV', 'GML', 'KML')
 6
 7invalid_drivers = ('Foo baz', 'clucka', 'ESRI Shp')
 8
 9aliases = {'eSrI' : 'ESRI Shapefile',
10           'TigER/linE' : 'TIGER',
11           'SHAPE' : 'ESRI Shapefile',
12           'sHp' : 'ESRI Shapefile',
13           }
14
15class DriverTest(unittest.TestCase):
16
17    def test01_valid_driver(self):
18        "Testing valid OGR Data Source Drivers."
19        for d in valid_drivers:
20            dr = Driver(d)
21            self.assertEqual(d, str(dr))
22
23    def test02_invalid_driver(self):
24        "Testing invalid OGR Data Source Drivers."
25        for i in invalid_drivers:
26            self.assertRaises(OGRException, Driver, i)
27
28    def test03_aliases(self):
29        "Testing driver aliases."
30        for alias, full_name in aliases.items():
31            dr = Driver(alias)
32            self.assertEqual(full_name, str(dr))
33
34def suite():
35    s = unittest.TestSuite()
36    s.addTest(unittest.makeSuite(DriverTest))
37    return s
38
39def run(verbosity=2):
40    unittest.TextTestRunner(verbosity=verbosity).run(suite())