Skip to content

Commit

Permalink
Merge pull request #33 from nansencenter/hotfix_compare_job
Browse files Browse the repository at this point in the history
Minor fixes to profile comparison job
  • Loading branch information
aperrin66 authored Oct 14, 2024
2 parents ae4277b + 3e2353a commit 83f5b13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions geospaas_rest_api/processing_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def get_signature(cls, parameters):
return celery.chain(
tasks_syntool.compare_profiles.signature(),
tasks_syntool.db_insert.signature(),
tasks_core.remove_downloaded.signature(),
)

@staticmethod
Expand All @@ -246,7 +247,8 @@ def check_parameters(parameters):
if ((not isinstance(parameters['model'], Sequence)) or
len(parameters['model']) != 2 or
not isinstance(parameters['model'][0], int) or
not isinstance(parameters['model'][1], str)):
not isinstance(parameters['model'][1], Sequence) or
any((not isinstance(p, str) for p in parameters['model'][1]))):
raise ValidationError("'model' must be a tuple (model_id, model_path)")

valid_profiles = True
Expand All @@ -257,7 +259,8 @@ def check_parameters(parameters):
if (not isinstance(profile_tuple, Sequence) or
len(profile_tuple) != 2 or
not isinstance(profile_tuple[0], int) or
not isinstance(profile_tuple[1], str)):
not isinstance(profile_tuple[1], Sequence) or
any((not isinstance(p, str) for p in profile_tuple[1]))):
valid_profiles = False
break
if not valid_profiles:
Expand Down
3 changes: 3 additions & 0 deletions geospaas_rest_api/tests/test_processing_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,14 @@ def test_get_signature(self):
"""Test getting the right signature"""
with mock.patch(
'geospaas_rest_api.processing_api.models.tasks_syntool') as mock_syntool_tasks, \
mock.patch(
'geospaas_rest_api.processing_api.models.tasks_core') as mock_core_tasks, \
mock.patch('celery.chain') as mock_chain:
_ = models.SyntoolCompareJob.get_signature({})
mock_chain.assert_called_once_with(
mock_syntool_tasks.compare_profiles.signature.return_value,
mock_syntool_tasks.db_insert.signature.return_value,
mock_core_tasks.remove_downloaded.signature.return_value,
)

def test_check_parameters_ok(self):
Expand Down

0 comments on commit 83f5b13

Please sign in to comment.