Skip to content

Commit

Permalink
[Backport 3.3.x][Fixes #9016] Geoserver importer NO_CRS task status d… (
Browse files Browse the repository at this point in the history
#9057)

* [Backport 3.3.x][Fixes #9016] Geoserver importer NO_CRS task status doesn't trigger the CRS selection step

* [CircleCI] Fix test cases
  • Loading branch information
Alessio Fabiani authored Apr 6, 2022
1 parent b5b97a7 commit c47be55
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ FAVORITE_ENABLED=True

# Upload Size Limiting
DEFAULT_MAX_UPLOAD_SIZE=5368709120
DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=100
4 changes: 2 additions & 2 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ def get_geonode_catalogue_service():
# },

CELERY_BEAT_SCHEDULER = os.environ.get(
'CELERY_BEAT_SCHEDULER', "django_celery_beat.schedulers:DatabaseScheduler")
'CELERY_BEAT_SCHEDULER', "celery.beat:PersistentScheduler")
CELERY_BEAT_SCHEDULE = {}

DELAYED_SECURITY_SIGNALS = ast.literal_eval(os.environ.get('DELAYED_SECURITY_SIGNALS', 'False'))
Expand Down Expand Up @@ -2200,7 +2200,7 @@ def get_geonode_catalogue_service():

DEFAULT_MAX_UPLOAD_SIZE = int(os.getenv('DEFAULT_MAX_UPLOAD_SIZE', 104857600)) # 100 MB
DEFAULT_BUFFER_CHUNK_SIZE = int(os.getenv('DEFAULT_BUFFER_CHUNK_SIZE', 64 * 1024))

DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER = int(os.getenv('DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER', 5))

'''
Default schema used to store extra and dynamic metadata for the resource
Expand Down
Binary file not shown.
29 changes: 28 additions & 1 deletion geonode/upload/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@
@override_settings(
DEBUG=True,
ALLOWED_HOSTS=['*'],
SITEURL=LIVE_SERVER_URL,
CSRF_COOKIE_SECURE=False,
CSRF_COOKIE_HTTPONLY=False,
CORS_ORIGIN_ALLOW_ALL=True,
SESSION_COOKIE_SECURE=False,
SITEURL=LIVE_SERVER_URL,
DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=5
)
class UploadApiTests(GeoNodeLiveTestSupport, APITestCase):

Expand Down Expand Up @@ -692,6 +693,32 @@ def test_rest_uploads_by_path(self):
self.assertEqual(len(response.data['uploads']), 0)
logger.debug(response.data)

def test_rest_uploads_no_crs(self):
"""
Ensure the upload process turns to `WAITING` status whenever a `CRS` info is missing from the GIS backend.
"""
# Try to upload a good raster file and check the session IDs
fname = os.path.join(os.getcwd(), 'geonode/tests/data/san_andres_y_providencia_coastline_no_prj.zip')
resp, data = self.rest_upload_file(fname)
self.assertEqual(resp.status_code, 200)
self.assertEqual(data['status'], 'incomplete')
self.assertTrue(data['success'])

url = reverse('uploads-list')
# Admin
self.assertTrue(self.client.login(username=GEONODE_USER, password=GEONODE_PASSWD))
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 5, response.data)
self.assertEqual(response.data['total'], 1, response.data['total'])
# Pagination
self.assertEqual(len(response.data['uploads']), 1)
logger.debug(response.data)
upload_data = response.data['uploads'][0]
self.assertIsNotNone(upload_data)
self.assertEqual(upload_data['name'], 'san_andres_y_providencia_coastline_no_prj', upload_data['name'])
self.assertEqual(upload_data['state'], Upload.STATE_WAITING, upload_data['state'])

@mock.patch("geonode.upload.forms.ValidationError")
@mock.patch("geonode.upload.uploadhandler.SimpleUploadedFile")
def test_rest_uploads_with_size_limit(self, mocked_uploaded_file, mocked_validation_error):
Expand Down
1 change: 1 addition & 0 deletions geonode/upload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def time_step_view(request, upload_session):
try:
upload_session.import_session = import_session.reload()
except gsimporter.api.NotFound as e:
logger.exception(e)
Upload.objects.invalidate_from_session(upload_session)
raise UploadException.from_exc(
_("The GeoServer Import Session is no more available"), e)
Expand Down

0 comments on commit c47be55

Please sign in to comment.