diff options
| author | John Tran <jtran@attinteractive.com> | 2011-05-02 18:04:29 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-05-02 18:04:29 +0000 |
| commit | 42c8e73994c7d787aef0e2d97ea162ee5a2e1304 (patch) | |
| tree | d6bacfaf33137aedf4dbc4d5b91221f8af138a11 /nova/tests | |
| parent | 585a1819f365018a4536bf7364722965ba994845 (diff) | |
| parent | c3ab4f023e2636e254f940e08da0aded42c0e96b (diff) | |
ApiError 'code' arg set to None, and will only display a 'code' as part of the str if specified.
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_exception.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/nova/tests/test_exception.py b/nova/tests/test_exception.py new file mode 100644 index 000000000..1b0e41d9a --- /dev/null +++ b/nova/tests/test_exception.py @@ -0,0 +1,34 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova import test +from nova import exception + + +class ApiErrorTestCase(test.TestCase): + def test_return_valid_error(self): + # without 'code' arg + err = exception.ApiError('fake error') + self.assertEqual(err.__str__(), 'fake error') + self.assertEqual(err.code, None) + self.assertEqual(err.message, 'fake error') + # with 'code' arg + err = exception.ApiError('fake error', 'blah code') + self.assertEqual(err.__str__(), 'blah code: fake error') + self.assertEqual(err.code, 'blah code') + self.assertEqual(err.message, 'fake error') |
