Fix usage of _fields method in provider_configuration.py
Apply _fields() method to each dict in the list. Change-Id: I9357212e203843ffa4a05216d9c79fe8831971a5 Closes-Bug: #1227971
This commit is contained in:
parent
1540cd3727
commit
534b062c82
@ -153,10 +153,10 @@ class ProviderConfiguration(object):
|
||||
return resource
|
||||
|
||||
def get_service_providers(self, filters=None, fields=None):
|
||||
res = [{'service_type': k[0],
|
||||
return [self._fields({'service_type': k[0],
|
||||
'name': k[1],
|
||||
'driver': v['driver'],
|
||||
'default': v['default']}
|
||||
'default': v['default']},
|
||||
fields)
|
||||
for k, v in self.providers.items()
|
||||
if self._check_entry(k, v, filters)]
|
||||
return self._fields(res, fields)
|
||||
|
@ -181,3 +181,21 @@ class ProviderConfigurationTestCase(base.BaseTestCase):
|
||||
'service_type': prov['service_type']}
|
||||
)
|
||||
self.assertEqual(p, [prov])
|
||||
|
||||
def test_get_service_providers_with_fields(self):
|
||||
provs = [{'service_type': constants.LOADBALANCER,
|
||||
'name': 'name',
|
||||
'driver': 'path',
|
||||
'default': False},
|
||||
{'service_type': constants.LOADBALANCER,
|
||||
'name': 'name2',
|
||||
'driver': 'path2',
|
||||
'default': False}]
|
||||
pconf = provconf.ProviderConfiguration(provs)
|
||||
for prov in provs:
|
||||
p = pconf.get_service_providers(
|
||||
filters={'name': [prov['name']],
|
||||
'service_type': prov['service_type']},
|
||||
fields=['name']
|
||||
)
|
||||
self.assertEqual(p, [{'name': prov['name']}])
|
||||
|
Loading…
Reference in New Issue
Block a user