cqle: Handle and return descriptive error for unknown table option

PYTHON-406
This commit is contained in:
Adam Holmberg
2015-10-09 15:02:59 -05:00
parent c0087da8f8
commit 3fdf3fb451
2 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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):