Stop using custom exception for filter
The loading of the module doesn't work and since we don't actually do anything with the exception, let's just use a generic exception instead. Change-Id: Ibe2b3a37d06ed5f740c9b9cf7d056a320f18dfa0 Closes-Bug: #1896252
This commit is contained in:
parent
d37dfddff3
commit
30406bf91f
|
@ -1,9 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
try:
|
||||
from ansible.module_utils import tripleo_common_utils as tc
|
||||
except ImportError:
|
||||
from tripleo_ansible.ansible_plugins.module_utils import tripleo_common_utils as tc
|
||||
from ansible.parsing.yaml.objects import AnsibleUnicode
|
||||
|
||||
|
||||
|
@ -34,7 +30,7 @@ class FilterModule(object):
|
|||
except ValueError as exc:
|
||||
msg = ("Invalid number in input param "
|
||||
"'range_list': %s" % exc)
|
||||
raise tc.DeriveParamsError(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
# here, num_list is a list of integers
|
||||
return [num for num in num_list if num not in exclude_num_list]
|
||||
|
@ -52,7 +48,7 @@ class FilterModule(object):
|
|||
num_list = self.convert_range_to_number_list(range_list)
|
||||
except Exception as err:
|
||||
msg = ('Derive Params Error: %s', err)
|
||||
raise tc.DeriveParamsError(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
# converts into comma delimited number list as string
|
||||
return ','.join([str(num) for num in num_list])
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
try:
|
||||
from ansible.module_utils import tripleo_common_utils as tc
|
||||
except ImportError:
|
||||
from tripleo_ansible.ansible_plugins.module_utils import tripleo_common_utils as tc
|
||||
from ansible.parsing.yaml.objects import AnsibleUnicode
|
||||
|
||||
|
||||
|
@ -37,7 +33,7 @@ class FilterModule(object):
|
|||
def range_list(self, num_list):
|
||||
if not num_list:
|
||||
msg = "Input param 'num_list' is blank."
|
||||
raise tc.DeriveParamsError(msg)
|
||||
raise Exception(msg)
|
||||
try:
|
||||
# splitting a string (comma delimited list) into
|
||||
# list of numbers
|
||||
|
@ -47,7 +43,7 @@ class FilterModule(object):
|
|||
except ValueError as exc:
|
||||
msg = ("Invalid number in input param "
|
||||
"'num_list': %s" % exc)
|
||||
raise tc.DeriveParamsError(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
range_list = self._convert_number_to_range_list(num_list)
|
||||
|
||||
|
|
|
@ -13,10 +13,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
from ansible.module_utils import tripleo_common_utils as tc
|
||||
except ImportError:
|
||||
from tripleo_ansible.ansible_plugins.module_utils import tripleo_common_utils as tc
|
||||
from tripleo_ansible.ansible_plugins.filter import number_list
|
||||
from tripleo_ansible.tests import base as tests_base
|
||||
|
||||
|
@ -53,13 +49,13 @@ class TestNumberListFilters(tests_base.TestCase):
|
|||
|
||||
def test_run_with_empty_input(self):
|
||||
range_list = ""
|
||||
self.assertRaises(tc.DeriveParamsError,
|
||||
self.assertRaises(Exception,
|
||||
self.filters.number_list,
|
||||
range_list)
|
||||
|
||||
def test_run_with_invalid_input(self):
|
||||
range_list = ",d"
|
||||
self.assertRaises(tc.DeriveParamsError,
|
||||
self.assertRaises(Exception,
|
||||
self.filters.number_list,
|
||||
range_list)
|
||||
|
||||
|
|
|
@ -13,10 +13,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
from ansible.module_utils import tripleo_common_utils as tc
|
||||
except ImportError:
|
||||
from tripleo_ansible.ansible_plugins.module_utils import tripleo_common_utils as tc
|
||||
from tripleo_ansible.ansible_plugins.filter import range_list
|
||||
from tripleo_ansible.tests import base as tests_base
|
||||
|
||||
|
@ -41,10 +37,10 @@ class TestRangeListFilters(tests_base.TestCase):
|
|||
|
||||
def test_run_with_empty_input(self):
|
||||
num_list = ""
|
||||
self.assertRaises(tc.DeriveParamsError,
|
||||
self.assertRaises(Exception,
|
||||
self.filters.range_list, num_list)
|
||||
|
||||
def test_run_with_invalid_input(self):
|
||||
num_list = ",d"
|
||||
self.assertRaises(tc.DeriveParamsError,
|
||||
self.assertRaises(Exception,
|
||||
self.filters.range_list, num_list)
|
||||
|
|
Loading…
Reference in New Issue