summaryrefslogtreecommitdiff
path: root/ceilometerclient/tests/test_exc.py
diff options
context:
space:
mode:
authorChris Dent <chdent@redhat.com>2015-03-12 13:31:06 +0000
committerChris Dent <chdent@redhat.com>2015-03-13 12:01:04 +0000
commitd9d8cc614eccaffefdfd4aa4f536745f0aabc5e3 (patch)
tree8ab56748455532a93e06fe98edddad60a423db15 /ceilometerclient/tests/test_exc.py
parente727d22bf1fc4ff613699560717e4aa460f60b73 (diff)
downloadpython-ceilometerclient-d9d8cc614eccaffefdfd4aa4f536745f0aabc5e3.tar.gz
Move unit tests into their own subdirectory
This is in preparation of moving functional tests currently in tempest in-tree. No surprises in this change: * move files * update the local imports Same number of tests run, all still pass. Change-Id: Ibfeac44421c5f36740b1377868f5ec469b2893f5
Diffstat (limited to 'ceilometerclient/tests/test_exc.py')
-rw-r--r--ceilometerclient/tests/test_exc.py71
1 files changed, 0 insertions, 71 deletions
diff --git a/ceilometerclient/tests/test_exc.py b/ceilometerclient/tests/test_exc.py
deleted file mode 100644
index 9c8f146..0000000
--- a/ceilometerclient/tests/test_exc.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2013 eNovance
-# 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.
-
-import json
-
-from ceilometerclient import exc
-from ceilometerclient.tests import utils
-
-HTTPEXCEPTIONS = {'HTTPBadRequest': exc.HTTPBadRequest,
- 'HTTPUnauthorized': exc.HTTPUnauthorized,
- 'HTTPForbidden': exc.HTTPForbidden,
- 'HTTPNotFound': exc.HTTPNotFound,
- 'HTTPMethodNotAllowed': exc.HTTPMethodNotAllowed,
- 'HTTPConflict': exc.HTTPConflict,
- 'HTTPOverLimit': exc.HTTPOverLimit,
- 'HTTPInternalServerError': exc.HTTPInternalServerError,
- 'HTTPNotImplemented': exc.HTTPNotImplemented,
- 'HTTPBadGateway': exc.HTTPBadGateway,
- 'HTTPServiceUnavailable': exc.HTTPServiceUnavailable}
-
-
-class HTTPExceptionsTest(utils.BaseTestCase):
- def test_str_no_details(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v()
- ret_str = k + " (HTTP " + str(exception.code) + ")"
- self.assertEqual(ret_str, str(exception))
-
- def test_str_no_json(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v(details="foo")
- ret_str = k + " (HTTP " + str(exception.code) + ")"
- self.assertEqual(ret_str, str(exception))
-
- def test_str_no_error_message(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v(details=json.dumps({}))
- ret_str = k + " (HTTP " + str(exception.code) + ")"
- self.assertEqual(ret_str, str(exception))
-
- def test_str_no_faultstring(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v(
- details=json.dumps({"error_message": {"foo": "bar"}}))
- ret_str = k + " (HTTP " + str(exception.code) + ")"
- self.assertEqual(ret_str, str(exception))
-
- def test_str_error_message_unknown_format(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v(details=json.dumps({"error_message": "oops"}))
- ret_str = k + " (HTTP " + str(exception.code) + ")"
- self.assertEqual(ret_str, str(exception))
-
- def test_str_faultstring(self):
- for k, v in HTTPEXCEPTIONS.items():
- exception = v(details=json.dumps(
- {"error_message": {"faultstring": "oops"}}))
- ret_str = k + " (HTTP " + str(exception.code) + ") ERROR oops"
- self.assertEqual(ret_str, str(exception))