Skip to content

Commit

Permalink
update parameter check tests for ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Nov 18, 2024
1 parent 59f6930 commit 899833a
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion geospaas_rest_api/tests/test_processing_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,26 @@ def test_check_parameters_wrong_converter_options_type(self):
models.ConvertJob.check_parameters(
{'dataset_id': 1, 'format': 'idf', 'converter_options': '2'})

def test_check_parameters_ttl(self):
"""`check_parameters()` must not raise an exception if 'ttl' is
a dict or None
"""
self.assertEqual(
models.ConvertJob.check_parameters(
{'dataset_id': 1, 'format': 'syntool', 'ttl': {'days': 2}}),
{'dataset_id': 1, 'format': 'syntool', 'ttl': {'days': 2}})
self.assertEqual(
models.ConvertJob.check_parameters(
{'dataset_id': 1, 'format': 'syntool', 'ttl': None}),
{'dataset_id': 1, 'format': 'syntool', 'ttl': None})

def test_check_parameters_wrong_ttl_type(self):
"""`check_parameters()` must raise an exception if the 'ttl'
value is of the wrong type"""
with self.assertRaises(ValidationError):
models.ConvertJob.check_parameters(
{'dataset_id': 1, 'format': 'syntool', 'ttl': 2})

def test_get_signature_syntool(self):
"""Test the right signature is returned"""
base_chain = celery.chain(
Expand Down Expand Up @@ -488,10 +508,36 @@ def test_check_parameters_ok(self):
self.assertDictEqual(
models.SyntoolCompareJob.check_parameters({
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz'))
'profiles': ((456, '/bar'), (789, '/baz')),
}),
{'model': (123, '/foo'), 'profiles': ((456, '/bar'), (789, '/baz'))})

def test_check_parameters_ttl(self):
"""ttl must be a dict or None"""
self.assertDictEqual(
models.SyntoolCompareJob.check_parameters({
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz')),
'ttl': {'days': 2},
}),
{
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz')),
'ttl': {'days': 2},
})
self.assertDictEqual(
models.SyntoolCompareJob.check_parameters({
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz')),
'ttl': None,
}),
{
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz')),
'ttl': None,
})


def test_check_parameters_unknown(self):
"""An error should be raised when an unknown parameter is given
"""
Expand Down Expand Up @@ -545,6 +591,13 @@ def test_check_parameters_wrong_type(self):
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, False))
})
# wrong ttl type
with self.assertRaises(ValidationError):
models.SyntoolCompareJob.check_parameters({
'model': (123, '/foo'),
'profiles': ((456, '/bar'), (789, '/baz')),
'ttl': 2,
})

def test_make_task_parameters(self):
"""Test that the right arguments are builts from the request
Expand Down

0 comments on commit 899833a

Please sign in to comment.