Fixed return value in row_model's get_items
In the non-standard case, row_model's get_items returns before the end of the function. Those return values were lists instead of the dicts required by a recent change. This change ensures get_items always returns a dict. Change-Id: Icd2511fc9d73d00268a44dda38542d02fc60fd97
This commit is contained in:
parent
85f9af6c9b
commit
c4edb0831b
@ -72,12 +72,12 @@ class RowModel(deepsix.deepSix):
|
||||
service_obj = self.engine.d6cage.service_object(service_name)
|
||||
if service_obj is None:
|
||||
LOG.info("Unknown data-source name %s," % service_name)
|
||||
return []
|
||||
return {"results": []}
|
||||
tablename = context['table_id']
|
||||
if tablename not in service_obj.state:
|
||||
LOG.info("Unknown tablename %s for datasource %s," %
|
||||
(service_name, tablename))
|
||||
return []
|
||||
return {"results": []}
|
||||
results = []
|
||||
for tup in service_obj.state[tablename]:
|
||||
d = {}
|
||||
@ -89,17 +89,17 @@ class RowModel(deepsix.deepSix):
|
||||
policy_name = context['policy_id']
|
||||
if policy_name not in self.engine.theory:
|
||||
LOG.info("Unknown policy name %s," % policy_name)
|
||||
return None
|
||||
return {"results": []}
|
||||
tablename = context['table_id']
|
||||
if tablename not in self.engine.theory[policy_name].tablenames():
|
||||
LOG.info("Unknown tablename %s for policy %s," %
|
||||
(tablename, policy_name))
|
||||
return []
|
||||
return {"results": []}
|
||||
arity = self.engine.theory[policy_name].get_arity(tablename)
|
||||
if arity is None:
|
||||
LOG.info("Unknown arity for table %s for policy %s," %
|
||||
(tablename, policy_name))
|
||||
return []
|
||||
return {"results": []}
|
||||
args = ["x" + str(i) for i in xrange(0, arity)]
|
||||
query = compile.parse1(tablename + "(" + ",".join(args) + ")")
|
||||
# LOG.debug("query: " + str(query))
|
||||
@ -122,7 +122,7 @@ class RowModel(deepsix.deepSix):
|
||||
# unknown
|
||||
else:
|
||||
LOG.info("Unknown source for row data %s," % str(context))
|
||||
results = []
|
||||
results = {"results": []}
|
||||
if gen_trace:
|
||||
return {"results": results, "trace": trace}
|
||||
return {"results": results}
|
||||
|
@ -375,6 +375,26 @@ class TestCongress(unittest.TestCase):
|
||||
self.assertTrue('trace' in ans, "Rows should have trace")
|
||||
self.assertEqual(len(ans['trace'].split('\n')), 16)
|
||||
|
||||
# unknown policy table
|
||||
context = {'policy_id': engine.DEFAULT_THEORY, 'table_id': 'unktable'}
|
||||
ans = api['row'].get_items({}, context=context)
|
||||
self.assertEqual(len(ans['results']), 0)
|
||||
|
||||
# unknown policy
|
||||
context = {'policy_id': 'unkpolicy', 'table_id': 'unktable'}
|
||||
ans = api['row'].get_items({}, context=context)
|
||||
self.assertEqual(len(ans['results']), 0)
|
||||
|
||||
# unknown datasource table
|
||||
context = {'ds_id': 'neutron', 'table_id': 'unktable'}
|
||||
ans = api['row'].get_items({}, context=context)
|
||||
self.assertEqual(len(ans['results']), 0)
|
||||
|
||||
# unknown datasource
|
||||
context = {'ds_id': 'unkds', 'table_id': 'unktable'}
|
||||
ans = api['row'].get_items({}, context=context)
|
||||
self.assertEqual(len(ans['results']), 0)
|
||||
|
||||
|
||||
def create_networkXnetwork_group(tablename):
|
||||
network_key_to_index = NeutronDriver.network_key_position_map()
|
||||
|
Loading…
Reference in New Issue
Block a user