cqle: Handle and return descriptive error for unknown table option
PYTHON-406
This commit is contained in:
@@ -422,7 +422,10 @@ def _update_options(model):
|
||||
|
||||
update_options = {}
|
||||
for name, value in model_options.items():
|
||||
existing_value = existing_options[name]
|
||||
try:
|
||||
existing_value = existing_options[name]
|
||||
except KeyError:
|
||||
raise KeyError("Invalid table option: '%s'; known options: %s" % (name, existing_options.keys()))
|
||||
if isinstance(existing_value, six.string_types):
|
||||
if value != existing_value:
|
||||
update_options[name] = value
|
||||
|
||||
@@ -217,6 +217,15 @@ class TablePropertiesTests(BaseCassEngTestCase):
|
||||
|
||||
self.assertDictContainsSubset(ModelWithTableProperties.__options__, table_options)
|
||||
|
||||
def test_bogus_option_update(self):
|
||||
sync_table(ModelWithTableProperties)
|
||||
option = 'no way will this ever be an option'
|
||||
try:
|
||||
ModelWithTableProperties.__options__[option] = 'what was I thinking?'
|
||||
self.assertRaisesRegexp(KeyError, "Invalid table option.*%s.*" % option, sync_table, ModelWithTableProperties)
|
||||
finally:
|
||||
ModelWithTableProperties.__options__.pop(option, None)
|
||||
|
||||
|
||||
class SyncTableTests(BaseCassEngTestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user