@@ -22,6 +22,8 @@ before_script:
|
||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install pysqlite; fi
|
||||
- if [[ $DB == mysql* ]]; then mysql -e 'create database test_w2p;'; fi
|
||||
- if [[ $DB == postgres* ]]; then psql -c 'create database test_w2p;' -U postgres; fi
|
||||
- if [[ $DB == postgres* ]]; then psql -c 'create extension postgis;' -U postgres -d test_w2p; fi
|
||||
|
||||
|
||||
# Install last sdk for app engine (update only whenever a new release is available)
|
||||
- if [[ $DB == google* ]]; then wget http://googleappengine.googlecode.com/files/google_appengine_1.8.9.zip -nv; fi
|
||||
|
||||
@@ -44,6 +44,9 @@ ALLOWED_DATATYPES = [
|
||||
'json',
|
||||
]
|
||||
|
||||
IS_POSTGRESQL = 'postgres' in DEFAULT_URI
|
||||
|
||||
|
||||
|
||||
def setUpModule():
|
||||
pass
|
||||
@@ -1528,6 +1531,31 @@ class TestQuotesByDefault(unittest.TestCase):
|
||||
def testme(self):
|
||||
return
|
||||
|
||||
|
||||
class TestGis(unittest.TestCase):
|
||||
|
||||
def testGeometry(self):
|
||||
from gluon.dal import geoPoint, geoLine, geoPolygon
|
||||
if not IS_POSTGRESQL: return
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'], ignore_field_case=False)
|
||||
t0 = db.define_table('t0', Field('point', 'geometry()'))
|
||||
t1 = db.define_table('t1', Field('line', 'geometry(public, 4326, 2)'))
|
||||
t2 = db.define_table('t2', Field('polygon', 'geometry(public, 4326, 2)'))
|
||||
t0.insert(point=geoPoint(1,1))
|
||||
text = db(db.t0.id).select(db.t0.point.st_astext()).first()[db.t0.point.st_astext()]
|
||||
self.assertEqual(text, "POINT(1 1)")
|
||||
t1.insert(line=geoLine((1,1),(2,2)))
|
||||
text = db(db.t1.id).select(db.t1.line.st_astext()).first()[db.t1.line.st_astext()]
|
||||
self.assertEqual(text, "LINESTRING(1 1,2 2)")
|
||||
t2.insert(polygon=geoPolygon((0,0),(2,0),(2,2),(0,2),(0,0)))
|
||||
text = db(db.t2.id).select(db.t2.polygon.st_astext()).first()[db.t2.polygon.st_astext()]
|
||||
self.assertEqual(text, "POLYGON((0 0,2 0,2 2,0 2,0 0))")
|
||||
t0.drop()
|
||||
t1.drop()
|
||||
t2.drop()
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
tearDownModule()
|
||||
|
||||
Reference in New Issue
Block a user