Skip to content

Commit

Permalink
- Fix QGis Server Integration Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jul 26, 2018
1 parent 7d86557 commit bd18aac
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 44 deletions.
65 changes: 33 additions & 32 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,31 +46,32 @@ 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'
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
# This is qgis server address
QGIS_SERVER_URL: http://localhost:9000/
Expand Down
8 changes: 4 additions & 4 deletions geonode/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

LOGIN_URL = "/accounts/login/"

logger = logging.getLogger("south").setLevel(logging.INFO)
logger = logging.getLogger(__name__)

# Reconnect post_save signals that is disconnected by populate_test_data
reconnect_signals()
Expand Down 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(qgis_server.BACKEND_PACKAGE)
@on_ogc_backend(geoserver.BACKEND_PACKAGE)
def test_add_delete_styles(self):
"""Style API Add/Delete interaction."""
# Check styles count
Expand Down Expand Up @@ -1703,14 +1703,14 @@ 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, 405)

# 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, 405)
self.client.logout()

# Use admin credentials
Expand Down
24 changes: 16 additions & 8 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def grab(src, dest, name):
def setup_geoserver(options):
"""Prepare a testing instance of GeoServer."""
# only start if using Geoserver backend
if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.qgis_server' or 'geonode.geoserver' not in INSTALLED_APPS:
return

download_dir = path('downloaded')
Expand Down Expand Up @@ -169,7 +170,8 @@ def setup_geoserver(options):
def setup_qgis_server(options):
"""Prepare a testing instance of QGIS Server."""
# only start if using QGIS Server backend
if 'geonode.qgis_server' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.geoserver':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.geoserver' or 'geonode.qgis_server' not in INSTALLED_APPS:
return

# QGIS Server testing instance run on top of docker
Expand Down Expand Up @@ -505,7 +507,8 @@ def stop_geoserver():
return

# only start if using Geoserver backend
if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.qgis_server' or 'geonode.geoserver' not in INSTALLED_APPS:
return
kill('java', 'geoserver')

Expand Down Expand Up @@ -542,7 +545,8 @@ def stop_qgis_server():
Stop QGIS Server Backend.
"""
# only start if using QGIS Server backend
if 'geonode.qgis_server' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.geoserver':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.geoserver' or 'geonode.qgis_server' not in INSTALLED_APPS:
return
port = options.get('qgis_server_port', '9000')

Expand Down Expand Up @@ -629,7 +633,8 @@ def start_geoserver(options):
return

# only start if using Geoserver backend
if 'geonode.geoserver' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.qgis_server':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.qgis_server' or 'geonode.geoserver' not in INSTALLED_APPS:
return

GEOSERVER_BASE_URL = OGC_SERVER['default']['LOCATION']
Expand Down Expand Up @@ -742,7 +747,8 @@ def start_geoserver(options):
def start_qgis_server():
"""Start QGIS Server instance with GeoNode related plugins."""
# only start if using QGIS Serrver backend
if 'geonode.qgis_server' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.geoserver':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.geoserver' or 'geonode.qgis_server' not in INSTALLED_APPS:
return
info('Starting up QGIS Server...')

Expand Down Expand Up @@ -816,7 +822,8 @@ def test_integration(options):
"""
Run GeoNode's Integration test suite against the external apps
"""
if 'geonode.qgis_server' not in INSTALLED_APPS or OGC_SERVER['default']['BACKEND'] == 'geonode.geoserver':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.geoserver' or 'geonode.qgis_server' not in INSTALLED_APPS:
call_task('stop_geoserver')
_reset()
# Start GeoServer
Expand Down Expand Up @@ -911,7 +918,8 @@ def run_tests(options):
call_task('test_integration', options={'name': 'geonode.tests.csw'})

# only start if using Geoserver backend
if 'geonode.geoserver' in INSTALLED_APPS and OGC_SERVER['default']['BACKEND'] == 'geonode.geoserver':
_backend = os.environ.get('BACKEND', OGC_SERVER['default']['BACKEND'])
if _backend == 'geonode.geoserver' and 'geonode.geoserver' in INSTALLED_APPS:
call_task('test_integration',
options={'name': 'geonode.upload.tests.integration',
'settings': 'geonode.upload.tests.test_settings'})
Expand Down

0 comments on commit bd18aac

Please sign in to comment.