Remove non-exception from EXCEPTION_DETAIL_MAPPINGS
Removes a non-exception from the map and adds tests to check the consistency of message_field.Action and .Detail fields. Updates test-requirements and lower-constraints to use the most recent version of ddt allowed by current upper-constraints. (An included test uses the idata decorator, which allows passing an iterator to the test data.) Closes-bug: #1822025 Change-Id: I0cad6589b145fac430942ccbb27279db7b3b152f
This commit is contained in:
parent
e27d781455
commit
a5b5d8e70e
@ -108,7 +108,6 @@ class Detail(object):
|
|||||||
'BackupLimitExceeded',
|
'BackupLimitExceeded',
|
||||||
'SnapshotLimitExceeded'],
|
'SnapshotLimitExceeded'],
|
||||||
NOT_ENOUGH_SPACE_FOR_IMAGE: ['ImageTooBig'],
|
NOT_ENOUGH_SPACE_FOR_IMAGE: ['ImageTooBig'],
|
||||||
UNMANAGE_ENC_NOT_SUPPORTED: ['UnmanageEncVolNotSupported'],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
|
import inspect
|
||||||
|
from itertools import chain
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
@ -23,6 +25,30 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class MessageFieldTest(test.TestCase):
|
class MessageFieldTest(test.TestCase):
|
||||||
|
def test_unique_action_ids(self):
|
||||||
|
"""Assert that no action_id is duplicated."""
|
||||||
|
action_ids = [x[0] for x in message_field.Action.ALL]
|
||||||
|
self.assertEqual(len(action_ids), len(set(action_ids)))
|
||||||
|
|
||||||
|
def test_unique_detail_ids(self):
|
||||||
|
"""Assert that no detail_id is duplicated."""
|
||||||
|
detail_ids = [x[0] for x in message_field.Detail.ALL]
|
||||||
|
self.assertEqual(len(detail_ids), len(set(detail_ids)))
|
||||||
|
|
||||||
|
known_exceptions = [
|
||||||
|
name for name, _ in
|
||||||
|
inspect.getmembers(exception, inspect.isclass)]
|
||||||
|
mapped_exceptions = list(chain.from_iterable(
|
||||||
|
message_field.Detail.EXCEPTION_DETAIL_MAPPINGS.values()))
|
||||||
|
|
||||||
|
@ddt.idata(mapped_exceptions)
|
||||||
|
def test_exception_detail_map_no_unknown_exceptions(self, exc):
|
||||||
|
"""Assert that only known exceptions are in the map."""
|
||||||
|
self.assertIn(exc, self.known_exceptions)
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
|
class MessageFieldFunctionsTest(test.TestCase):
|
||||||
|
|
||||||
@ddt.data({'id': '001', 'content': 'schedule allocate volume'},
|
@ddt.data({'id': '001', 'content': 'schedule allocate volume'},
|
||||||
{'id': '002', 'content': 'attach volume'},
|
{'id': '002', 'content': 'attach volume'},
|
||||||
|
@ -17,7 +17,7 @@ contextlib2==0.5.5
|
|||||||
coverage==4.0
|
coverage==4.0
|
||||||
cryptography==2.1
|
cryptography==2.1
|
||||||
cursive==0.2.1
|
cursive==0.2.1
|
||||||
ddt==1.0.1
|
ddt==1.2.1
|
||||||
debtcollector==1.19.0
|
debtcollector==1.19.0
|
||||||
decorator==3.4.0
|
decorator==3.4.0
|
||||||
defusedxml==0.5.0
|
defusedxml==0.5.0
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||||
|
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
ddt>=1.0.1 # MIT
|
ddt>=1.2.1 # MIT
|
||||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
mock>=2.0.0 # BSD
|
mock>=2.0.0 # BSD
|
||||||
os-api-ref>=1.4.0 # Apache-2.0
|
os-api-ref>=1.4.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user