Merge "Remove non-exception from EXCEPTION_DETAIL_MAPPINGS"

This commit is contained in:
Zuul 2019-04-03 20:12:23 +00:00 committed by Gerrit Code Review
commit 4abccc9fab
4 changed files with 28 additions and 3 deletions

View File

@ -108,7 +108,6 @@ class Detail(object):
'BackupLimitExceeded',
'SnapshotLimitExceeded'],
NOT_ENOUGH_SPACE_FOR_IMAGE: ['ImageTooBig'],
UNMANAGE_ENC_NOT_SUPPORTED: ['UnmanageEncVolNotSupported'],
}

View File

@ -11,6 +11,8 @@
# under the License.
import ddt
import inspect
from itertools import chain
from oslo_config import cfg
@ -23,6 +25,30 @@ CONF = cfg.CONF
@ddt.ddt
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'},
{'id': '002', 'content': 'attach volume'},

View File

@ -17,7 +17,7 @@ contextlib2==0.5.5
coverage==4.0
cryptography==2.1
cursive==0.2.1
ddt==1.0.1
ddt==1.2.1
debtcollector==1.19.0
decorator==3.4.0
defusedxml==0.5.0

View File

@ -6,7 +6,7 @@
hacking!=0.13.0,<0.14,>=0.12.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
mock>=2.0.0 # BSD
os-api-ref>=1.4.0 # Apache-2.0