Fix bug in get_capabilities behavior in DB drivers
Capabilities API returns NotImplementedError in case of SQLAlchemy driver. This issue is fixed in this patch by moving the function into the proper class. Another issue is, that get_capabilities function overwrites the DEFAULT_CAPABILITIES dict in base.py every time, when the function is invoked. This behavior was changed to create a CAPABILITIES dict in each DB driver's __init__ function by making a deep copy from DEFAULT_CAPABILITIES and updating the new dict with the AVAILABLE_CAPABILITIES. get_capabilities now returns the newly created CAPABILITIES dict without modifying it. Tests were also added to check that get_capabilities returns the expected values for each DB driver. Fixes-bug: #1292611 Change-Id: I725751b600bf462c19278e5785eb2d8530023083
This commit is contained in:
@@ -295,3 +295,48 @@ class AlarmTestPagination(test_storage_scenarios.AlarmTestBase,
|
||||
'counter-name-foo')
|
||||
except base.MultipleResultsFound:
|
||||
self.assertTrue(True)
|
||||
|
||||
|
||||
class CapabilitiesTest(MongoDBEngineTestBase):
|
||||
# Check the returned capabilities list, which is specific to each DB
|
||||
# driver
|
||||
|
||||
def test_capabilities(self):
|
||||
expected_capabilities = {
|
||||
'meters': {'pagination': False,
|
||||
'query': {'simple': True,
|
||||
'metadata': True,
|
||||
'complex': False}},
|
||||
'resources': {'pagination': False,
|
||||
'query': {'simple': True,
|
||||
'metadata': True,
|
||||
'complex': False}},
|
||||
'samples': {'pagination': False,
|
||||
'groupby': False,
|
||||
'query': {'simple': True,
|
||||
'metadata': True,
|
||||
'complex': True}},
|
||||
'statistics': {'pagination': False,
|
||||
'groupby': True,
|
||||
'query': {'simple': True,
|
||||
'metadata': True,
|
||||
'complex': False},
|
||||
'aggregation': {'standard': True,
|
||||
'selectable': {
|
||||
'max': True,
|
||||
'min': True,
|
||||
'sum': True,
|
||||
'avg': True,
|
||||
'count': True,
|
||||
'stddev': True,
|
||||
'cardinality': True}}
|
||||
},
|
||||
'alarms': {'query': {'simple': True,
|
||||
'complex': True},
|
||||
'history': {'query': {'simple': True,
|
||||
'complex': True}}},
|
||||
'events': {'query': {'simple': False}}
|
||||
}
|
||||
|
||||
actual_capabilities = self.conn.get_capabilities()
|
||||
self.assertEqual(expected_capabilities, actual_capabilities)
|
||||
|
||||
Reference in New Issue
Block a user