Merge branch '2641-spatial-widgets-new-theme' of github.com:okfn/ckanext-spatial into 2641-spatial-widgets-new-theme
This commit is contained in:
commit
917ce0124e
|
@ -24,7 +24,7 @@ def setup(srid=None):
|
|||
define_spatial_tables(srid)
|
||||
log.debug('Spatial tables defined in memory')
|
||||
|
||||
if model.repo.are_tables_created():
|
||||
if model.package_table.exists():
|
||||
if not Table('geometry_columns',meta.metadata).exists() or \
|
||||
not Table('spatial_ref_sys',meta.metadata).exists():
|
||||
raise Exception('The spatial extension is enabled, but PostGIS ' + \
|
||||
|
|
|
@ -16,18 +16,19 @@ class TestDatasetMap(FunctionalTestCase,SpatialTestBase):
|
|||
|
||||
def test_map_shown(self):
|
||||
CreateTestData.create()
|
||||
|
||||
|
||||
extra_environ = {'REMOTE_USER': 'annafan'}
|
||||
name = 'annakarenina'
|
||||
|
||||
offset = url_for(controller='package', action='edit',id=name)
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=extra_environ)
|
||||
assert 'Edit - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
fv[prefix+'extras__1__key'] = u'spatial'
|
||||
fv[prefix+'extras__1__value'] = self.geojson_examples['point']
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=extra_environ)
|
||||
assert not 'Error' in res, res
|
||||
|
||||
# Load the dataset page and check if the libraries have been loaded
|
||||
|
|
|
@ -14,6 +14,11 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
cls.extra_environ = {'REMOTE_USER': 'annafan'}
|
||||
|
||||
def setup(self):
|
||||
CreateTestData.create()
|
||||
|
||||
|
@ -24,7 +29,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
name = 'test-spatial-dataset-1'
|
||||
|
||||
offset = url_for(controller='package', action='new')
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=self.extra_environ)
|
||||
assert 'Add - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
|
@ -32,7 +37,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
fv[prefix+'extras__0__key'] = u'spatial'
|
||||
fv[prefix+'extras__0__value'] = self.geojson_examples['point']
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=self.extra_environ)
|
||||
assert not 'Error' in res, res
|
||||
|
||||
package = Package.get(name)
|
||||
|
@ -52,7 +57,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
name = 'test-spatial-dataset-2'
|
||||
|
||||
offset = url_for(controller='package', action='new')
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=self.extra_environ)
|
||||
assert 'Add - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
|
@ -60,7 +65,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
fv[prefix+'extras__0__key'] = u'spatial'
|
||||
fv[prefix+'extras__0__value'] = u'{"Type":Bad Json]'
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=self.extra_environ)
|
||||
assert 'Error' in res, res
|
||||
assert 'Spatial' in res
|
||||
assert 'Error decoding JSON object' in res
|
||||
|
@ -72,7 +77,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
name = 'test-spatial-dataset-3'
|
||||
|
||||
offset = url_for(controller='package', action='new')
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=self.extra_environ)
|
||||
assert 'Add - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
|
@ -80,7 +85,7 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
fv[prefix+'extras__0__key'] = u'spatial'
|
||||
fv[prefix+'extras__0__value'] = u'{"Type":"Bad_GeoJSON","a":2}'
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=self.extra_environ)
|
||||
assert 'Error' in res, res
|
||||
assert 'Spatial' in res
|
||||
assert 'Error creating geometry' in res
|
||||
|
@ -93,14 +98,14 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
name = 'annakarenina'
|
||||
|
||||
offset = url_for(controller='package', action='edit',id=name)
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=self.extra_environ)
|
||||
assert 'Edit - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
fv[prefix+'extras__1__key'] = u'spatial'
|
||||
fv[prefix+'extras__1__value'] = self.geojson_examples['point']
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=self.extra_environ)
|
||||
assert not 'Error' in res, res
|
||||
|
||||
package = Package.get(name)
|
||||
|
@ -117,13 +122,13 @@ class TestPackageController(FunctionalTestCase,SpatialTestBase):
|
|||
|
||||
# Update the spatial extra
|
||||
offset = url_for(controller='package', action='edit',id=name)
|
||||
res = self.app.get(offset)
|
||||
res = self.app.get(offset, extra_environ=self.extra_environ)
|
||||
assert 'Edit - Datasets' in res
|
||||
fv = res.forms['dataset-edit']
|
||||
prefix = ''
|
||||
fv[prefix+'extras__1__value'] = self.geojson_examples['polygon']
|
||||
|
||||
res = fv.submit('save')
|
||||
res = fv.submit('save', extra_environ=self.extra_environ)
|
||||
assert not 'Error' in res, res
|
||||
|
||||
# Check that the PackageExtent object has been updated
|
||||
|
|
Loading…
Reference in New Issue