summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2013-02-11 16:10:25 -0600
committerSteve Martinelli <stevemar@ca.ibm.com>2013-02-11 16:10:25 -0600
commit79001ce88a7c0a2197cad32ae84565822ad9b40e (patch)
tree972665833d863072758b1524846c214cff7269dd
parent7072b4f802ff5567f0781f89f360c5be43a7977e (diff)
downloadpython-openstackclient-79001ce88a7c0a2197cad32ae84565822ad9b40e.tar.gz
Add volume test cases and structure
add basic unit test for client update/modify test_shell.py to include volume Change-Id: I7d08e15a2711da5e51590b8a82eca3a1234962f8
-rw-r--r--tests/test_shell.py11
-rw-r--r--tests/volume/__init__.py14
-rw-r--r--tests/volume/test_volume.py51
3 files changed, 74 insertions, 2 deletions
diff --git a/tests/test_shell.py b/tests/test_shell.py
index d259785f..6b9b0760 100644
--- a/tests/test_shell.py
+++ b/tests/test_shell.py
@@ -32,10 +32,12 @@ DEFAULT_SERVICE_URL = "http://127.0.0.1:8771/v3.0/"
DEFAULT_COMPUTE_API_VERSION = "2"
DEFAULT_IDENTITY_API_VERSION = "2.0"
DEFAULT_IMAGE_API_VERSION = "v2"
+DEFAULT_VOLUME_API_VERSION = "1"
LIB_COMPUTE_API_VERSION = "2"
LIB_IDENTITY_API_VERSION = "2.0"
LIB_IMAGE_API_VERSION = "1.0"
+LIB_VOLUME_API_VERSION = "1"
def make_shell():
@@ -106,6 +108,8 @@ class TestShell(utils.TestCase):
default_args["identity_api_version"])
self.assertEqual(_shell.options.os_image_api_version,
default_args["image_api_version"])
+ self.assertEqual(_shell.options.os_volume_api_version,
+ default_args["volume_api_version"])
class TestShellHelp(TestShell):
@@ -252,6 +256,7 @@ class TestShellCli(TestShell):
"OS_COMPUTE_API_VERSION": DEFAULT_COMPUTE_API_VERSION,
"OS_IDENTITY_API_VERSION": DEFAULT_IDENTITY_API_VERSION,
"OS_IMAGE_API_VERSION": DEFAULT_IMAGE_API_VERSION,
+ "OS_VOLUME_API_VERSION": DEFAULT_VOLUME_API_VERSION,
}
self.orig_env, os.environ = os.environ, env.copy()
@@ -271,7 +276,8 @@ class TestShellCli(TestShell):
kwargs = {
"compute_api_version": DEFAULT_COMPUTE_API_VERSION,
"identity_api_version": DEFAULT_IDENTITY_API_VERSION,
- "image_api_version": DEFAULT_IMAGE_API_VERSION
+ "image_api_version": DEFAULT_IMAGE_API_VERSION,
+ "volume_api_version": DEFAULT_VOLUME_API_VERSION
}
self._assert_cli(flag, kwargs)
@@ -281,6 +287,7 @@ class TestShellCli(TestShell):
kwargs = {
"compute_api_version": LIB_COMPUTE_API_VERSION,
"identity_api_version": LIB_IDENTITY_API_VERSION,
- "image_api_version": LIB_IMAGE_API_VERSION
+ "image_api_version": LIB_IMAGE_API_VERSION,
+ "volume_api_version": LIB_VOLUME_API_VERSION
}
self._assert_cli(flag, kwargs)
diff --git a/tests/volume/__init__.py b/tests/volume/__init__.py
new file mode 100644
index 00000000..ebf59b32
--- /dev/null
+++ b/tests/volume/__init__.py
@@ -0,0 +1,14 @@
+# Copyright 2013 OpenStack, LLC.
+#
+# 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.
+#
diff --git a/tests/volume/test_volume.py b/tests/volume/test_volume.py
new file mode 100644
index 00000000..8c60dd12
--- /dev/null
+++ b/tests/volume/test_volume.py
@@ -0,0 +1,51 @@
+# Copyright 2013 OpenStack, LLC.
+#
+# 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 mock
+
+from openstackclient.common import clientmanager
+from openstackclient.volume import client as volume_client
+from tests import utils
+
+
+AUTH_TOKEN = "foobar"
+AUTH_URL = "http://0.0.0.0"
+
+
+class FakeClient(object):
+ def __init__(self, endpoint=None, **kwargs):
+ self.client = mock.MagicMock()
+ self.client.auth_token = AUTH_TOKEN
+ self.client.auth_url = AUTH_URL
+
+
+class TestVolume(utils.TestCase):
+ def setUp(self):
+ super(TestVolume, self).setUp()
+
+ api_version = {"volume": "1"}
+
+ volume_client.API_VERSIONS = {
+ "1": "tests.volume.test_volume.FakeClient"
+ }
+
+ self.cm = clientmanager.ClientManager(token=AUTH_TOKEN,
+ url=AUTH_URL,
+ auth_url=AUTH_URL,
+ api_version=api_version)
+
+ def test_make_client(self):
+ self.assertEqual(self.cm.volume.client.auth_token, AUTH_TOKEN)
+ self.assertEqual(self.cm.volume.client.auth_url, AUTH_URL)