mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
gis: modifed tests and mixin to use the HAS_GDAL flag.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6413 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
07963be5df
commit
1025326602
@ -1,15 +1,10 @@
|
||||
from warnings import warn
|
||||
|
||||
# GEOS is a requirement
|
||||
# GEOS is a requirement, GDAL is not
|
||||
from django.contrib.gis.geos import GEOSGeometry
|
||||
|
||||
# GDAL is a lot more complicated to install, and isn't necessary for many
|
||||
# operations.
|
||||
try:
|
||||
from django.contrib.gis.gdal import HAS_GDAL
|
||||
if HAS_GDAL:
|
||||
from django.contrib.gis.gdal import OGRGeometry, SpatialReference
|
||||
HAS_GDAL = True
|
||||
except ImportError, e:
|
||||
HAS_GDAL = False
|
||||
|
||||
# Until model subclassing is a possibility, a mixin class is used to add
|
||||
# the necessary functions that may be contributed for geographic objects.
|
||||
|
@ -1,23 +1,23 @@
|
||||
import sys
|
||||
from copy import copy
|
||||
from unittest import TestSuite, TextTestRunner
|
||||
import sys
|
||||
from django.contrib.gis.gdal import HAS_GDAL
|
||||
|
||||
|
||||
# Tests that do not require setting up and tearing down a spatial database.
|
||||
test_suite_names = [
|
||||
'test_geos',
|
||||
'test_measure',
|
||||
]
|
||||
try:
|
||||
# GDAL tests
|
||||
import django.contrib.gis.gdal
|
||||
if HAS_GDAL:
|
||||
test_suite_names += [
|
||||
'test_gdal_driver',
|
||||
'test_gdal_ds',
|
||||
'test_gdal_geom',
|
||||
'test_gdal_srs',
|
||||
'test_spatialrefsys',
|
||||
]
|
||||
except ImportError, e:
|
||||
]
|
||||
else:
|
||||
print >>sys.stderr, "GDAL not available - no GDAL tests will be run."
|
||||
|
||||
test_models = ['geoapp']
|
||||
@ -35,27 +35,28 @@ def run(verbosity=1):
|
||||
TextTestRunner(verbosity=verbosity).run(suite())
|
||||
|
||||
def run_tests(module_list, verbosity=1, interactive=True):
|
||||
"""Run the tests that require creation of a spatial database. Does not
|
||||
yet work on Windows platforms.
|
||||
"""
|
||||
Run the tests that require creation of a spatial database. Does not
|
||||
yet work on Windows platforms.
|
||||
|
||||
In order to run geographic model tests the DATABASE_USER will require
|
||||
superuser priviliges. To accomplish this outside the `postgres` user,
|
||||
create your own PostgreSQL database as a user:
|
||||
(1) Initialize database: `initdb -D /path/to/user/db`
|
||||
(2) If there's already a Postgres instance on the machine, it will need
|
||||
to use a different TCP port than 5432. Edit postgresql.conf (in
|
||||
/path/to/user/db) to change the database port (e.g. `port = 5433`).
|
||||
(3) Start this database `pg_ctl -D /path/to/user/db start`
|
||||
superuser priviliges. To accomplish this outside the `postgres` user,
|
||||
create your own PostgreSQL database as a user:
|
||||
(1) Initialize database: `initdb -D /path/to/user/db`
|
||||
(2) If there's already a Postgres instance on the machine, it will need
|
||||
to use a different TCP port than 5432. Edit postgresql.conf (in
|
||||
/path/to/user/db) to change the database port (e.g. `port = 5433`).
|
||||
(3) Start this database `pg_ctl -D /path/to/user/db start`
|
||||
|
||||
Make sure your settings.py matches the settings of the user database. For example, set the
|
||||
same port number (`DATABASE_PORT=5433`). DATABASE_NAME or TEST_DATABSE_NAME must be set,
|
||||
along with DATABASE_USER.
|
||||
same port number (`DATABASE_PORT=5433`). DATABASE_NAME or TEST_DATABSE_NAME must be set,
|
||||
along with DATABASE_USER.
|
||||
|
||||
In settings.py set TEST_RUNNER='django.contrib.gis.tests.run_tests'.
|
||||
|
||||
Finally, this assumes that the PostGIS SQL files (lwpostgis.sql and spatial_ref_sys.sql)
|
||||
are installed in /usr/local/share. If they are not, add `POSTGIS_SQL_PATH=/path/to/sql`
|
||||
in your settings.py.
|
||||
are installed in /usr/local/share. If they are not, add `POSTGIS_SQL_PATH=/path/to/sql`
|
||||
in your settings.py.
|
||||
|
||||
The tests may be run by invoking `./manage.py test`.
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user