Add missing "listener_id" attribute to L7 policy

Adding missing "listener_id" attribute to the L7 policy resource.
Updating unit tests.

Change-Id: I1e7a173642f87851c35dd8b644d1f06653d7776a
Closes-Bug: 1587901
This commit is contained in:
Evgeny Fedoruk 2016-06-06 06:05:29 -07:00
parent 602f3a2304
commit ab59666a18
2 changed files with 6 additions and 2 deletions

View File

@ -603,7 +603,7 @@ class L7Policy(BaseDataModel):
def to_api_dict(self): def to_api_dict(self):
ret_dict = super(L7Policy, self).to_dict( ret_dict = super(L7Policy, self).to_dict(
listener=False, listener_id=False, listener=False, listener_id=True,
provisioning_status=False, redirect_pool=False) provisioning_status=False, redirect_pool=False)
ret_dict['listeners'] = [] ret_dict['listeners'] = []
if self.listener: if self.listener:

View File

@ -1051,7 +1051,7 @@ class TestLoadBalancerGraphCreation(LbaasPluginDbTestCase):
self.assertEqual(expected_graph, actual) self.assertEqual(expected_graph, actual)
for observed_listener in observed_listeners: for observed_listener in observed_listeners:
self.assertTrue(observed_listener.get('id')) self.assertTrue(observed_listener.get('id'))
observed_listener.pop('id') listener_id = observed_listener.pop('id')
default_pool = observed_listener.get('default_pool') default_pool = observed_listener.get('default_pool')
l7_policies = observed_listener.get('l7policies') l7_policies = observed_listener.get('l7policies')
if default_pool: if default_pool:
@ -1067,7 +1067,10 @@ class TestLoadBalancerGraphCreation(LbaasPluginDbTestCase):
if l7_policies: if l7_policies:
for policy in l7_policies: for policy in l7_policies:
self.assertTrue(policy.get('id')) self.assertTrue(policy.get('id'))
self.assertTrue(policy.get('listener_id'))
self.assertEqual(listener_id, policy.get('listener_id'))
policy.pop('id') policy.pop('id')
policy.pop('listener_id')
r_pool = policy.get('redirect_pool') r_pool = policy.get('redirect_pool')
rules = policy.get('rules') rules = policy.get('rules')
if r_pool: if r_pool:
@ -2353,6 +2356,7 @@ class LbaasL7Tests(ListenerTestBase):
with self.listener(loadbalancer_id=self.lb_id) as listener: with self.listener(loadbalancer_id=self.lb_id) as listener:
listener_id = listener['listener']['id'] listener_id = listener['listener']['id']
expected['listener_id'] = listener_id
with self.l7policy(listener_id, name="0") as p: with self.l7policy(listener_id, name="0") as p:
req = self.new_show_request('l7policies', req = self.new_show_request('l7policies',
p['l7policy']['id'], p['l7policy']['id'],