Fix the logic of do_hashmap_mapping_list
Only give the group_id should be allowed to do_hashmap_mapping_list, and add the corresponding test case. Depends-On: I4fe27a07e369728396d440b6b2f3462ee74d5f4d Change-Id: Ia4272fff33b70db0dc24f7bf0a6d5971504cee7a
This commit is contained in:
parent
9acc36b4ca
commit
b24e261143
|
@ -622,6 +622,21 @@ class MappingManagerTest(utils.BaseTestCase):
|
|||
self.api = client.BaseClient(self.http_client)
|
||||
self.mgr = hashmap.MappingManager(self.api)
|
||||
|
||||
def test_get_mappings_by_group(self):
|
||||
mappings = self.mgr.findall(group_id=GROUP2['group_id'])
|
||||
expect = [
|
||||
'GET', ('/v1/rating/module_config/hashmap/mappings?group_id=' +
|
||||
GROUP2['group_id'])]
|
||||
self.http_client.assert_called(*expect)
|
||||
self.assertEqual(1, len(mappings))
|
||||
mapping = mappings[0]
|
||||
self.assertEqual(FIELD1['field_id'], mapping.field_id)
|
||||
self.assertEqual(FIELD_MAPPING1['group_id'], mapping.group_id)
|
||||
self.assertEqual(FIELD_MAPPING1['mapping_id'], mapping.mapping_id)
|
||||
self.assertEqual(FIELD_MAPPING1['value'], mapping.value)
|
||||
self.assertEqual(FIELD_MAPPING1['cost'], mapping.cost)
|
||||
self.assertEqual(FIELD_MAPPING1['type'], mapping.type)
|
||||
|
||||
def test_get_a_mapping(self):
|
||||
resource = self.mgr.get(mapping_id=FIELD_MAPPING1['mapping_id'])
|
||||
expect = [
|
||||
|
@ -700,6 +715,27 @@ class ThresholdManagerTest(utils.BaseTestCase):
|
|||
self.api = client.BaseClient(self.http_client)
|
||||
self.mgr = hashmap.ThresholdManager(self.api)
|
||||
|
||||
def test_get_thresholds_by_group(self):
|
||||
mappings = self.mgr.findall(group_id=GROUP3['group_id'])
|
||||
expect = [
|
||||
'GET', ('/v1/rating/module_config/hashmap/thresholds?group_id=' +
|
||||
GROUP3['group_id'])]
|
||||
self.http_client.assert_called(*expect)
|
||||
self.assertEqual(1, len(mappings))
|
||||
mapping = mappings[0]
|
||||
self.assertEqual(SERVICE_THRESHOLD1['threshold_id'],
|
||||
mapping.threshold_id)
|
||||
self.assertEqual(SERVICE_THRESHOLD1['service_id'],
|
||||
mapping.service_id)
|
||||
self.assertEqual(SERVICE_THRESHOLD1['group_id'],
|
||||
mapping.group_id)
|
||||
self.assertEqual(SERVICE_THRESHOLD1['level'],
|
||||
mapping.level)
|
||||
self.assertEqual(SERVICE_THRESHOLD1['cost'],
|
||||
mapping.cost)
|
||||
self.assertEqual(SERVICE_THRESHOLD1['map_type'],
|
||||
mapping.map_type)
|
||||
|
||||
def test_get_a_threshold(self):
|
||||
resource = self.mgr.get(
|
||||
threshold_id=SERVICE_THRESHOLD1['threshold_id'])
|
||||
|
|
|
@ -202,8 +202,10 @@ def do_hashmap_mapping_update(cc, args={}):
|
|||
required=False)
|
||||
def do_hashmap_mapping_list(cc, args={}):
|
||||
"""List mappings."""
|
||||
if args.service_id is None and args.field_id is None:
|
||||
raise exc.CommandError("Provide either service-id or field-id")
|
||||
if (args.group_id is None and
|
||||
args.service_id is None and args.field_id is None):
|
||||
raise exc.CommandError("Provide either group-id, service-id or "
|
||||
"field-id")
|
||||
try:
|
||||
mappings = cc.hashmap.mappings.list(service_id=args.service_id,
|
||||
field_id=args.field_id,
|
||||
|
|
Loading…
Reference in New Issue