Browse Source

Fix session persistemce profiles list

resource_type is a static method and not a property

Change-Id: Ia1e90b2127a865b5997c8f6bec29fb410f417f65
changes/92/780892/1
asarfaty 4 weeks ago
committed by Adit Sarfaty
parent
commit
6cd14b3149
2 changed files with 31 additions and 5 deletions
  1. +29
    -3
      vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py
  2. +2
    -2
      vmware_nsxlib/v3/policy/lb_resources.py

+ 29
- 3
vmware_nsxlib/tests/unit/v3/policy/test_lb_resources.py View File

@ -394,7 +394,7 @@ class TestPolicyLBCookiePersistenceProfile(
with mock.patch.object(
self.policy_api, "list",
return_value={'results': [
{'resource_type': self.resourceApi.entry_def.resource_type,
{'resource_type': self.resourceApi.entry_def.resource_type(),
'display_name': name}]}) as api_call:
obj = self.resourceApi.get_by_name(name, tenant=TEST_TENANT)
self.assertIsNotNone(obj)
@ -407,7 +407,7 @@ class TestPolicyLBCookiePersistenceProfile(
with mock.patch.object(
self.policy_api, "list",
return_value={'results': [
{'resource_type': self.resourceApi.entry_def.resource_type,
{'resource_type': self.resourceApi.entry_def.resource_type(),
'display_name': 'profile1'},
{'resource_type': 'wrong_type',
'display_name': 'profile2'}]}) as api_call:
@ -538,7 +538,7 @@ class TestPolicyLBSourceIpProfileApi(test_resources.NsxPolicyLibTestCase):
with mock.patch.object(
self.policy_api, "list",
return_value={'results': [
{'resource_type': self.resourceApi.entry_def.resource_type,
{'resource_type': self.resourceApi.entry_def.resource_type(),
'display_name': name}]}) as api_call:
obj = self.resourceApi.get_by_name(name, tenant=TEST_TENANT)
self.assertIsNotNone(obj)
@ -548,6 +548,32 @@ class TestPolicyLBSourceIpProfileApi(test_resources.NsxPolicyLibTestCase):
self.assert_called_with_def(api_call, expected_def)
def test_list(self):
profiles = [{'resource_type': 'LBSourceIpPersistenceProfile',
'id': 'default-source-ip-lb-persistence-profile',
'display_name': 'default-source-ip-profile'}]
with mock.patch.object(self.policy_api, "list",
return_value={'results': profiles}) as api_call:
result = self.resourceApi.list(tenant=TEST_TENANT)
expected_def = (
lb_defs.LBSourceIpPersistenceProfileDef(
tenant=TEST_TENANT))
self.assert_called_with_def(api_call, expected_def)
self.assertEqual(profiles, result)
def test_list_different_type(self):
profiles = [{'resource_type': 'LBSourceCookiePersistenceProfile',
'id': 'default-source-ip-lb-persistence-profile',
'display_name': 'default-source-ip-profile'}]
with mock.patch.object(self.policy_api, "list",
return_value={'results': profiles}) as api_call:
result = self.resourceApi.list(tenant=TEST_TENANT)
expected_def = (
lb_defs.LBSourceIpPersistenceProfileDef(
tenant=TEST_TENANT))
self.assert_called_with_def(api_call, expected_def)
self.assertEqual([], result)
def test_list_empty(self):
with mock.patch.object(self.policy_api, "list",
return_value={'results': []}) as api_call:
result = self.resourceApi.list(tenant=TEST_TENANT)


+ 2
- 2
vmware_nsxlib/v3/policy/lb_resources.py View File

@ -379,7 +379,7 @@ class NsxPolicyLoadBalancerCookiePersistenceProfileApi(
results = self._list(lb_cookie_persistence_profile_def)
# filter the results by resource type
return [res for res in results
if res.get('resource_type') == self.entry_def.resource_type]
if res.get('resource_type') == self.entry_def.resource_type()]
def update(self, persistence_profile_id,
name=IGNORE,
@ -443,7 +443,7 @@ class NsxPolicyLoadBalancerSourceIpPersistenceProfileApi(
results = self._list(lb_source_ip_persistence_profile_def)
# filter the results by resource type
return [res for res in results
if res.get('resource_type') == self.entry_def.resource_type]
if res.get('resource_type') == self.entry_def.resource_type()]
def update(self, persistence_profile_id,
name=IGNORE,


Loading…
Cancel
Save