fake_new_volume.id)
self.assertIsNone(volume.migration_status)
+ def test_check_volume_filters_true(self):
+ """Test bootable as filter for true"""
+ volume_api = cinder.volume.api.API()
+ filters = {'bootable': 'TRUE'}
+
+ # To convert filter value to True or False
+ volume_api.check_volume_filters(filters)
+
+ # Confirming converted filter value against True
+ self.assertTrue(filters['bootable'])
+
+ def test_check_volume_filters_false(self):
+ """Test bootable as filter for false"""
+ volume_api = cinder.volume.api.API()
+ filters = {'bootable': 'false'}
+
+ # To convert filter value to True or False
+ volume_api.check_volume_filters(filters)
+
+ # Confirming converted filter value against False
+ self.assertEqual(False, filters['bootable'])
+
+ def test_check_volume_filters_invalid(self):
+ """Test bootable as filter"""
+ volume_api = cinder.volume.api.API()
+ filters = {'bootable': 'invalid'}
+
+ # To convert filter value to True or False
+ volume_api.check_volume_filters(filters)
+
+ # Confirming converted filter value against invalid value
+ self.assertTrue(filters['bootable'])
+
def test_update_volume_readonly_flag(self):
"""Test volume readonly flag can be updated at API level."""
# create a volume and assign to host
return self.volume_rpcapi.list_replication_targets(ctxt, volume)
def check_volume_filters(self, filters):
+ '''Sets the user filter value to accepted format'''
booleans = self.db.get_booleans_for_table('volume')
+
+ # To translate any true/false equivalent to True/False
+ # which is only acceptable format in database queries.
+ accepted_true = ['True', 'true', 'TRUE']
+ accepted_false = ['False', 'false', 'FALSE']
for k, v in filters.items():
try:
if k in booleans:
- filters[k] = bool(v)
+ if v in accepted_false:
+ filters[k] = False
+ elif v in accepted_true:
+ filters[k] = True
+ else:
+ filters[k] = bool(v)
else:
filters[k] = ast.literal_eval(v)
except (ValueError, SyntaxError):