Skip to content

Commit

Permalink
[Fixes #12657] Rename ACTIONS into TASKS
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Oct 16, 2024
1 parent b6a26f3 commit 4faae74
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions geonode/upload/handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BaseVectorFileHandler(BaseHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (), # define the list of the step (celery task) needed to execute the action for the resource
exa.COPY.value: (),
exa.DELETE.value: (),
Expand Down Expand Up @@ -242,7 +242,7 @@ class NewVectorFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
10 changes: 5 additions & 5 deletions geonode/upload/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BaseHandler(ABC):

REGISTRY = []

ACTIONS = {
TASKS = {
exa.IMPORT.value: (),
exa.COPY.value: (),
exa.DELETE.value: (),
Expand All @@ -70,9 +70,9 @@ def get_registry(cls):

@classmethod
def get_task_list(cls, action) -> tuple:
if action not in cls.ACTIONS:
if action not in cls.TASKS:
raise Exception("The requested action is not implemented yet")
return cls.ACTIONS.get(action)
return cls.TASKS.get(action)

@property
def default_geometry_column_name(self):
Expand Down Expand Up @@ -140,7 +140,7 @@ def can_do(action) -> bool:
the Handler must be ready to handle them. If is not in the actual
flow the already in place flow is followd
"""
return action in BaseHandler.ACTIONS
return action in BaseHandler.TASKS

@staticmethod
def extract_params_from_data(_data):
Expand Down Expand Up @@ -300,7 +300,7 @@ def overwrite_resourcehandlerinfo(
return self.create_resourcehandlerinfo(handler_module_path, resource, execution_id, **kwargs)

def rollback(self, exec_id, rollback_from_step, action_to_rollback, *args, **kwargs):
steps = self.ACTIONS.get(action_to_rollback)
steps = self.TASKS.get(action_to_rollback)

if rollback_from_step not in steps:
logger.info(f"Step not found {rollback_from_step}, skipping")
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MetadataFileHandler(BaseHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: ("start_import", "geonode.upload.import_resource"),
ira.ROLLBACK.value: (
"start_rollback",
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/common/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def can_do(action) -> bool:
This endpoint will return True or False if with the info provided
the handler is able to handle the file or not
"""
return action in BaseHandler.ACTIONS
return action in BaseHandler.TASKS

@staticmethod
def create_error_log(exc, task_name, *args):
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/common/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BaseRemoteResourceHandler(BaseHandler):
As first implementation only remote 3dtiles are supported
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/common/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.import_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 3)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 3)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
"start_copy",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_url_is_invalid(self):
with self.assertRaises(ImportException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/common/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def can_do(action) -> bool:
This endpoint will return True or False if with the info provided
the handler is able to handle the file or not
"""
return action in BaseHandler.ACTIONS
return action in BaseHandler.TASKS

@staticmethod
def create_error_log(exc, task_name, *args):
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/csv/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CSVFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/csv/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
Expand All @@ -68,8 +68,8 @@ def test_task_list_is_the_expected_one_geojson(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_csv_is_invalid(self):
with self.assertRaises(InvalidCSVException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/geojson/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GeoJsonFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/geojson/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_copy(self):
expected = (
Expand All @@ -65,8 +65,8 @@ def test_task_list_is_the_expected_one_copy(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_parallelism_is_met(self):
parallelism, created = UploadParallelismLimit.objects.get_or_create(slug="default_max_parallel_uploads")
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/geotiff/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GeoTiffFileHandler(BaseRasterFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/geotiff/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_copy(self):
expected = (
Expand All @@ -58,8 +58,8 @@ def test_task_list_is_the_expected_one_copy(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_parallelism_is_met(self):
parallelism, created = UploadParallelismLimit.objects.get_or_create(slug="default_max_parallel_uploads")
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/gpkg/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GPKGFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/gpkg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
Expand All @@ -66,8 +66,8 @@ def test_task_list_is_the_expected_one_geojson(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_gpkg_is_invalid(self):
with self.assertRaises(InvalidGeopackageException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/kml/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class KMLFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/kml/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
Expand All @@ -60,8 +60,8 @@ def test_task_list_is_the_expected_one_geojson(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_kml_is_invalid(self):
with self.assertRaises(InvalidKmlException) as _exc:
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/remote/tests/test_3dtiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.import_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 3)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 3)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
"start_copy",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_url_is_invalid(self):
with self.assertRaises(ImportException) as _exc:
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/remote/tests/test_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.import_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 3)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 3)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_geojson(self):
expected = (
"start_copy",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_url_is_invalid(self):
with self.assertRaises(ImportException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/shapefile/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ShapeFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/shapefile/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 4)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 4)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_copy_task_list_is_the_expected_one(self):
expected = (
Expand All @@ -73,8 +73,8 @@ def test_copy_task_list_is_the_expected_one(self):
"geonode.upload.publish_resource",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 5)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_parallelism_is_met(self):
parallelism, created = UploadParallelismLimit.objects.get_or_create(slug="default_max_parallel_uploads")
Expand Down
4 changes: 2 additions & 2 deletions geonode/upload/handlers/sld/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def test_task_list_is_the_expected_one(self):
"start_import",
"geonode.upload.import_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_is_valid_should_raise_exception_if_the_sld_is_invalid(self):
with self.assertRaises(InvalidSldException) as _exc:
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/tiles3d/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Tiles3DFileHandler(BaseVectorFileHandler):
It must provide the task_lists required to comple the upload
"""

ACTIONS = {
TASKS = {
exa.IMPORT.value: (
"start_import",
"geonode.upload.import_resource",
Expand Down
8 changes: 4 additions & 4 deletions geonode/upload/handlers/tiles3d/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ def test_task_list_is_the_expected_one(self):
"geonode.upload.import_resource",
"geonode.upload.create_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 3)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 3)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_task_list_is_the_expected_one_copy(self):
expected = (
"start_copy",
"geonode.upload.copy_geonode_resource",
)
self.assertEqual(len(self.handler.ACTIONS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["copy"])
self.assertEqual(len(self.handler.TASKS["copy"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["copy"])

def test_is_valid_should_raise_exception_if_the_parallelism_is_met(self):
parallelism, created = UploadParallelismLimit.objects.get_or_create(slug="default_max_parallel_uploads")
Expand Down
4 changes: 2 additions & 2 deletions geonode/upload/handlers/xml/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_task_list_is_the_expected_one(self):
"start_import",
"geonode.upload.import_resource",
)
self.assertEqual(len(self.handler.ACTIONS["import"]), 2)
self.assertTupleEqual(expected, self.handler.ACTIONS["import"])
self.assertEqual(len(self.handler.TASKS["import"]), 2)
self.assertTupleEqual(expected, self.handler.TASKS["import"])

def test_is_valid_should_raise_exception_if_the_xml_is_invalid(self):
with self.assertRaises(InvalidXmlException) as _exc:
Expand Down

0 comments on commit 4faae74

Please sign in to comment.