diff --git a/glanceclient/v2/tasks.py b/glanceclient/v2/tasks.py index 37801915..8ad039f3 100644 --- a/glanceclient/v2/tasks.py +++ b/glanceclient/v2/tasks.py @@ -110,7 +110,7 @@ class Controller(object): try: setattr(task, key, value) except warlock.InvalidOperation as e: - raise TypeError(unicode(e)) + raise TypeError(utils.exception_to_str(e)) resp, body = self.http_client.post(url, data=task) #NOTE(flwang): remove 'self' for now until we have an elegant diff --git a/tests/v2/test_tasks.py b/tests/v2/test_tasks.py index a5491a3b..4e1f78c4 100644 --- a/tests/v2/test_tasks.py +++ b/tests/v2/test_tasks.py @@ -187,6 +187,7 @@ schema_fixtures = { 'result': {}, 'message': {}, }, + 'additionalProperties': False, } ) } @@ -275,3 +276,10 @@ class TestController(testtools.TestCase): task = self.controller.create(**properties) self.assertEqual(task.id, '3a4560a1-e585-443e-9b39-553b46ec92d1') self.assertEqual(task.type, 'import') + + def test_create_task_invalid_property(self): + properties = { + 'type': 'import', + 'bad_prop': 'value', + } + self.assertRaises(TypeError, self.controller.create, **properties)