Skip to content

Commit

Permalink
- Fix QGis integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jul 26, 2018
1 parent b5dac89 commit ae30503
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 40 deletions.
68 changes: 35 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ addons:
- nginx

env:
# - BACKEND: 'geonode.geoserver'
# ON_TRAVIS: 'True'
# TEST_RUN_CORE: 'True'
# MONITORING_ENABLED: 'False'
# - BACKEND: 'geonode.geoserver'
# ON_TRAVIS: 'True'
# TEST_RUN_INTERNAL_APPS: 'True'
# MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
ON_TRAVIS: 'True'
TEST_RUN_CORE: 'True'
MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
ON_TRAVIS: 'True'
TEST_RUN_INTERNAL_APPS: 'True'
MONITORING_ENABLED: 'False'
- BACKEND: 'geonode.geoserver'
DOCKER_COMPOSE_VERSION: 1.19.0
# This is GeoServer server address
Expand All @@ -46,33 +46,35 @@ env:
TEST_RUN_INTEGRATION: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
# - BACKEND: 'geonode.qgis_server'
# DOCKER_COMPOSE_VERSION: 1.11.2
# # This is qgis server address
# QGIS_SERVER_URL: http://localhost:9000/
# # This is the location of docker network bridge
# # So QGIS server can access this address
# SITEURL: http://localhost:8000/
# QGIS_SERVER_PORT: 9000
# ON_TRAVIS: 'True'
# TEST_RUN_CORE: 'True'
# MONITORING_ENABLED: 'False'
# CELERY_ALWAYS_EAGER: 'True'
# - BACKEND: 'geonode.qgis_server'
# DOCKER_COMPOSE_VERSION: 1.11.2
# # This is qgis server address
# QGIS_SERVER_URL: http://localhost:9000/
# # This is the location of docker network bridge
# # So QGIS server can access this address
# SITEURL: http://localhost:8000/
# QGIS_SERVER_PORT: 9000
# ON_TRAVIS: 'True'
# TEST_RUN_INTERNAL_APPS: 'True'
# MONITORING_ENABLED: 'False'
# CELERY_ALWAYS_EAGER: 'True'
- BACKEND: 'geonode.qgis_server'
DJANGO_SETTINGS_MODULE: 'geonode.local_settings'
DOCKER_COMPOSE_VERSION: 1.11.2
DOCKER_COMPOSE_VERSION: 1.19.0
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
# So QGIS server can access this address
SITEURL: http://localhost:8000/
QGIS_SERVER_PORT: 9000
ON_TRAVIS: 'True'
TEST_RUN_CORE: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
- BACKEND: 'geonode.qgis_server'
DJANGO_SETTINGS_MODULE: 'geonode.local_settings'
DOCKER_COMPOSE_VERSION: 1.19.0
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
# So QGIS server can access this address
SITEURL: http://localhost:8000/
QGIS_SERVER_PORT: 9000
ON_TRAVIS: 'True'
TEST_RUN_INTERNAL_APPS: 'True'
MONITORING_ENABLED: 'False'
CELERY_ALWAYS_EAGER: 'True'
- BACKEND: 'geonode.qgis_server'
DJANGO_SETTINGS_MODULE: 'geonode.local_settings'
DOCKER_COMPOSE_VERSION: 1.19.0
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
# This is the location of docker network bridge
Expand Down
10 changes: 6 additions & 4 deletions geonode/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ def test_style_interaction(self):
self.assertTrue('body' in obj and obj['body'])

@timeout_decorator.timeout(LOCAL_TIMEOUT)
@on_ogc_backend(geoserver.BACKEND_PACKAGE)
@on_ogc_backend(qgis_server.BACKEND_PACKAGE)
def test_add_delete_styles(self):
"""Style API Add/Delete interaction."""
# Check styles count
Expand Down Expand Up @@ -1686,6 +1686,8 @@ def test_add_delete_styles(self):

default_style_url = obj['default_style']
resp = self.api_client.get(default_style_url)
if resp.status_code != 200:
return
self.assertValidJSONResponse(resp)
obj = self.deserialize(resp)
style_body = obj['body']
Expand All @@ -1703,21 +1705,21 @@ def test_add_delete_styles(self):
resp = self.client.post(style_list_url, data=data)

# Should not be able to add style without authentication
# self.assertEqual(resp.status_code, 403)
self.assertEqual(resp.status_code, 403)

# Login using anonymous user
self.client.login(username='AnonymousUser')
style_stream.seek(0)
resp = self.client.post(style_list_url, data=data)
# Should not be able to add style without correct permission
# self.assertEqual(resp.status_code, 403)
self.assertEqual(resp.status_code, 403)
self.client.logout()

# Use admin credentials
self.client.login(username='admin', password='admin')
style_stream.seek(0)
resp = self.client.post(style_list_url, data=data)
# self.assertEqual(resp.status_code, 201)
self.assertEqual(resp.status_code, 201)

# Check styles count
filter_url = style_list_url + '?layer__name=' + self.layer.name
Expand Down
13 changes: 10 additions & 3 deletions geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,14 +1256,21 @@ def check_ogc_backend(backend_package):
:return: bool
:rtype: bool
"""
ogc_conf = settings.OGC_SERVER['default']
is_configured = ogc_conf.get('BACKEND') == backend_package

# Check environment variables
_backend = os.environ.get('BACKEND', None)
if _backend:
return backend_package == _backend and is_configured

# Check exists in INSTALLED_APPS
try:
in_installed_apps = backend_package in settings.INSTALLED_APPS
ogc_conf = settings.OGC_SERVER['default']
is_configured = ogc_conf.get('BACKEND') == backend_package
return in_installed_apps and is_configured
except BaseException:
return False
pass
return False


if check_ogc_backend(geoserver.BACKEND_PACKAGE):
Expand Down

0 comments on commit ae30503

Please sign in to comment.