app/django/contrib/gis/tests/test_gdal_driver.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Tue, 27 Jan 2009 21:56:32 +0000
changeset 1015 b9d51be5104a
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Add profiling support to Melange. By assigning profile_main_as_logs or profile_main_as_html to main variable you can turn on profiling. profile_main_as_logs will log profile data to App Engine console logs, profile_main_as_html will show profile data as html at the bottom of the page. If you want to profile app on deployed app just set the profiling function and deploy it. Patch by: Pawel Solyga Reviewed by: to-be-reviewed

import os, os.path, unittest
from django.contrib.gis.gdal import Driver, OGRException

valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN',
                 'Memory', 'CSV', 'GML', 'KML')

invalid_drivers = ('Foo baz', 'clucka', 'ESRI Shp')

aliases = {'eSrI' : 'ESRI Shapefile',
           'TigER/linE' : 'TIGER',
           'SHAPE' : 'ESRI Shapefile',
           'sHp' : 'ESRI Shapefile',
           }

class DriverTest(unittest.TestCase):

    def test01_valid_driver(self):
        "Testing valid OGR Data Source Drivers."
        for d in valid_drivers:
            dr = Driver(d)
            self.assertEqual(d, str(dr))

    def test02_invalid_driver(self):
        "Testing invalid OGR Data Source Drivers."
        for i in invalid_drivers:
            self.assertRaises(OGRException, Driver, i)

    def test03_aliases(self):
        "Testing driver aliases."
        for alias, full_name in aliases.items():
            dr = Driver(alias)
            self.assertEqual(full_name, str(dr))

def suite():
    s = unittest.TestSuite()
    s.addTest(unittest.makeSuite(DriverTest))
    return s

def run(verbosity=2):
    unittest.TextTestRunner(verbosity=verbosity).run(suite())