summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py14
-rw-r--r--tests/common/test_clientmanager.py35
-rw-r--r--tests/common/test_commandmanager.py71
-rw-r--r--tests/common/test_parseractions.py104
-rw-r--r--tests/compute/__init__.py14
-rw-r--r--tests/compute/test_compute.py50
-rw-r--r--tests/identity/__init__.py14
-rw-r--r--tests/identity/test_identity.py48
-rw-r--r--tests/image/__init__.py14
-rw-r--r--tests/image/test_image.py51
-rw-r--r--tests/test_shell.py293
-rw-r--r--tests/utils.py59
-rw-r--r--tests/volume/__init__.py14
-rw-r--r--tests/volume/test_volume.py51
14 files changed, 0 insertions, 832 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index 85ac2501..00000000
--- a/tests/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2012-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/common/test_clientmanager.py b/tests/common/test_clientmanager.py
deleted file mode 100644
index fe99c599..00000000
--- a/tests/common/test_clientmanager.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2012-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.
-#
-
-from openstackclient.common import clientmanager
-from tests import utils
-
-
-class Container(object):
- attr = clientmanager.ClientCache(lambda x: object())
-
- def __init__(self):
- pass
-
-
-class TestClientManager(utils.TestCase):
- def setUp(self):
- super(TestClientManager, self).setUp()
-
- def test_singleton(self):
- # NOTE(dtroyer): Verify that the ClientCache descriptor only invokes
- # the factory one time and always returns the same value after that.
- c = Container()
- self.assertEqual(c.attr, c.attr)
diff --git a/tests/common/test_commandmanager.py b/tests/common/test_commandmanager.py
deleted file mode 100644
index f0a0b341..00000000
--- a/tests/common/test_commandmanager.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2012-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 commandmanager
-from tests import utils
-
-
-class FakeCommand(object):
- @classmethod
- def load(cls):
- return cls
-
- def __init__(self):
- return
-
-FAKE_CMD_ONE = FakeCommand
-FAKE_CMD_TWO = FakeCommand
-FAKE_CMD_ALPHA = FakeCommand
-FAKE_CMD_BETA = FakeCommand
-
-
-class FakeCommandManager(commandmanager.CommandManager):
- commands = {}
-
- def _load_commands(self, group=None):
- if not group:
- self.commands['one'] = FAKE_CMD_ONE
- self.commands['two'] = FAKE_CMD_TWO
- else:
- self.commands['alpha'] = FAKE_CMD_ALPHA
- self.commands['beta'] = FAKE_CMD_BETA
-
-
-class TestCommandManager(utils.TestCase):
- def test_add_command_group(self):
- mgr = FakeCommandManager('test')
-
- # Make sure add_command() still functions
- mock_cmd_one = mock.Mock()
- mgr.add_command('mock', mock_cmd_one)
- cmd_mock, name, args = mgr.find_command(['mock'])
- self.assertEqual(cmd_mock, mock_cmd_one)
-
- # Find a command added in initialization
- cmd_one, name, args = mgr.find_command(['one'])
- self.assertEqual(cmd_one, FAKE_CMD_ONE)
-
- # Load another command group
- mgr.add_command_group('latin')
-
- # Find a new command
- cmd_alpha, name, args = mgr.find_command(['alpha'])
- self.assertEqual(cmd_alpha, FAKE_CMD_ALPHA)
-
- # Ensure that the original commands were not overwritten
- cmd_two, name, args = mgr.find_command(['two'])
- self.assertEqual(cmd_two, FAKE_CMD_TWO)
diff --git a/tests/common/test_parseractions.py b/tests/common/test_parseractions.py
deleted file mode 100644
index f48c4d72..00000000
--- a/tests/common/test_parseractions.py
+++ /dev/null
@@ -1,104 +0,0 @@
-# Copyright 2012-2013 OpenStack Foundation
-#
-# 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 argparse
-
-from openstackclient.common import parseractions
-from tests import utils
-
-
-class TestKeyValueAction(utils.TestCase):
- def test_good_values(self):
- parser = argparse.ArgumentParser()
-
- # Set up our typical usage
- parser.add_argument(
- '--property',
- metavar='<key=value>',
- action=parseractions.KeyValueAction,
- help='Property to store for this volume '
- '(repeat option to set multiple properties)',
- )
-
- results = parser.parse_args([
- '--property', 'red=',
- '--property', 'green=100%',
- '--property', 'blue=50%',
- ])
-
- actual = getattr(results, 'property', {})
- # All should pass through unmolested
- expect = {'red': '', 'green': '100%', 'blue': '50%'}
- self.assertDictEqual(expect, actual)
-
- def test_default_values(self):
- parser = argparse.ArgumentParser()
-
- # Set up our typical usage
- parser.add_argument(
- '--property',
- metavar='<key=value>',
- action=parseractions.KeyValueAction,
- default={'green': '20%', 'format': '#rgb'},
- help='Property to store for this volume '
- '(repeat option to set multiple properties)',
- )
-
- results = parser.parse_args([
- '--property', 'red=',
- '--property', 'green=100%',
- '--property', 'blue=50%',
- ])
-
- actual = getattr(results, 'property', {})
- # Verify green default is changed, format default is unchanged
- expect = {'red': '', 'green': '100%', 'blue': '50%', 'format': '#rgb'}
- self.assertDictEqual(expect, actual)
-
- def test_error_values(self):
- parser = argparse.ArgumentParser()
-
- # Set up our typical usage
- parser.add_argument(
- '--property',
- metavar='<key=value>',
- action=parseractions.KeyValueAction,
- default={'green': '20%', 'blue': '40%'},
- help='Property to store for this volume '
- '(repeat option to set multiple properties)',
- )
-
- results = parser.parse_args([
- '--property', 'red',
- '--property', 'green=100%',
- '--property', 'blue',
- ])
-
- failhere = None
- actual = getattr(results, 'property', {})
- # Verify non-existant red key
- try:
- failhere = actual['red']
- except Exception as e:
- self.assertTrue(type(e) == KeyError)
- # Verify removal of blue key
- try:
- failhere = actual['blue']
- except Exception as e:
- self.assertTrue(type(e) == KeyError)
- # There should be no red or blue
- expect = {'green': '100%'}
- self.assertDictEqual(expect, actual)
- self.assertEqual(failhere, None)
diff --git a/tests/compute/__init__.py b/tests/compute/__init__.py
deleted file mode 100644
index ebf59b32..00000000
--- a/tests/compute/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/compute/test_compute.py b/tests/compute/test_compute.py
deleted file mode 100644
index 2673f994..00000000
--- a/tests/compute/test_compute.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# 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.compute import client as compute_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_url = AUTH_URL
-
-
-class TestCompute(utils.TestCase):
- def setUp(self):
- super(TestCompute, self).setUp()
-
- api_version = {"compute": "2"}
-
- compute_client.API_VERSIONS = {
- "2": "tests.compute.test_compute.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.compute.client.auth_token, AUTH_TOKEN)
- self.assertEqual(self.cm.compute.client.auth_url, AUTH_URL)
diff --git a/tests/identity/__init__.py b/tests/identity/__init__.py
deleted file mode 100644
index ebf59b32..00000000
--- a/tests/identity/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/identity/test_identity.py b/tests/identity/test_identity.py
deleted file mode 100644
index 52bbd222..00000000
--- a/tests/identity/test_identity.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# 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.
-#
-
-from openstackclient.common import clientmanager
-from openstackclient.identity import client as identity_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.auth_token = AUTH_TOKEN
- self.auth_url = AUTH_URL
-
-
-class TestIdentity(utils.TestCase):
- def setUp(self):
- super(TestIdentity, self).setUp()
-
- api_version = {"identity": "2.0"}
-
- identity_client.API_VERSIONS = {
- "2.0": "tests.identity.test_identity.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.identity.auth_token, AUTH_TOKEN)
- self.assertEqual(self.cm.identity.auth_url, AUTH_URL)
diff --git a/tests/image/__init__.py b/tests/image/__init__.py
deleted file mode 100644
index ebf59b32..00000000
--- a/tests/image/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/image/test_image.py b/tests/image/test_image.py
deleted file mode 100644
index 60b21429..00000000
--- a/tests/image/test_image.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# 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.image import client as image_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 TestImage(utils.TestCase):
- def setUp(self):
- super(TestImage, self).setUp()
-
- api_version = {"image": "2"}
-
- image_client.API_VERSIONS = {
- "2": "tests.image.test_image.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.image.client.auth_token, AUTH_TOKEN)
- self.assertEqual(self.cm.image.client.auth_url, AUTH_URL)
diff --git a/tests/test_shell.py b/tests/test_shell.py
deleted file mode 100644
index d0eb5b0d..00000000
--- a/tests/test_shell.py
+++ /dev/null
@@ -1,293 +0,0 @@
-# Copyright 2012-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
-import os
-
-from openstackclient import shell
-from tests import utils
-
-
-DEFAULT_USERNAME = "username"
-DEFAULT_PASSWORD = "password"
-DEFAULT_TENANT_ID = "xxxx-yyyy-zzzz"
-DEFAULT_TENANT_NAME = "tenant"
-DEFAULT_TOKEN = "token"
-DEFAULT_REGION_NAME = "ZZ9_Plural_Z_Alpha"
-DEFAULT_AUTH_URL = "http://127.0.0.1:5000/v2.0/"
-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 = "2"
-LIB_VOLUME_API_VERSION = "1"
-
-
-def make_shell():
- """Create a new command shell and mock out some bits."""
- _shell = shell.OpenStackShell()
- _shell.command_manager = mock.Mock()
-
- return _shell
-
-
-def fake_execute(shell, cmd):
- """Pretend to execute shell commands."""
- return shell.run(cmd.split())
-
-
-class TestShell(utils.TestCase):
- def setUp(self):
- super(TestShell, self).setUp()
- patch = "openstackclient.shell.OpenStackShell.run_subcommand"
- self.cmd_patch = mock.patch(patch)
- self.cmd_save = self.cmd_patch.start()
- self.app = mock.Mock("Test Shell")
-
- def tearDown(self):
- super(TestShell, self).tearDown()
- self.cmd_patch.stop()
-
- def _assert_password_auth(self, cmd_options, default_args):
- with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
- self.app):
- _shell, _cmd = make_shell(), cmd_options + " list tenant"
- fake_execute(_shell, _cmd)
-
- self.app.assert_called_with(["list", "tenant"])
- self.assertEqual(_shell.options.os_auth_url,
- default_args["auth_url"])
- self.assertEqual(_shell.options.os_tenant_id,
- default_args["tenant_id"])
- self.assertEqual(_shell.options.os_tenant_name,
- default_args["tenant_name"])
- self.assertEqual(_shell.options.os_username,
- default_args["username"])
- self.assertEqual(_shell.options.os_password,
- default_args["password"])
- self.assertEqual(_shell.options.os_region_name,
- default_args["region_name"])
-
- def _assert_token_auth(self, cmd_options, default_args):
- with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
- self.app):
- _shell, _cmd = make_shell(), cmd_options + " list role"
- fake_execute(_shell, _cmd)
-
- self.app.assert_called_with(["list", "role"])
- self.assertEqual(_shell.options.os_token, default_args["os_token"])
- self.assertEqual(_shell.options.os_url, default_args["os_url"])
-
- def _assert_cli(self, cmd_options, default_args):
- with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
- self.app):
- _shell, _cmd = make_shell(), cmd_options + " list server"
- fake_execute(_shell, _cmd)
-
- self.app.assert_called_with(["list", "server"])
- self.assertEqual(_shell.options.os_compute_api_version,
- default_args["compute_api_version"])
- self.assertEqual(_shell.options.os_identity_api_version,
- 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):
- """Test the deferred help flag"""
- def setUp(self):
- super(TestShellHelp, self).setUp()
- self.orig_env, os.environ = os.environ, {}
-
- def tearDown(self):
- super(TestShellHelp, self).tearDown()
- os.environ = self.orig_env
-
- def test_help_options(self):
- flag = "-h list server"
- kwargs = {
- "deferred_help": True,
- }
- with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
- self.app):
- _shell, _cmd = make_shell(), flag
- fake_execute(_shell, _cmd)
-
- self.assertEqual(_shell.options.deferred_help,
- kwargs["deferred_help"])
-
-
-class TestShellPasswordAuth(TestShell):
- def setUp(self):
- super(TestShellPasswordAuth, self).setUp()
- self.orig_env, os.environ = os.environ, {}
-
- def tearDown(self):
- super(TestShellPasswordAuth, self).tearDown()
- os.environ = self.orig_env
-
- def test_only_url_flow(self):
- flag = "--os-auth-url " + DEFAULT_AUTH_URL
- kwargs = {
- "auth_url": DEFAULT_AUTH_URL,
- "tenant_id": "",
- "tenant_name": "",
- "username": "",
- "password": "",
- "region_name": ""
- }
- self._assert_password_auth(flag, kwargs)
-
- def test_only_tenant_id_flow(self):
- flag = "--os-tenant-id " + DEFAULT_TENANT_ID
- kwargs = {
- "auth_url": "",
- "tenant_id": DEFAULT_TENANT_ID,
- "tenant_name": "",
- "username": "",
- "password": "",
- "region_name": ""
- }
- self._assert_password_auth(flag, kwargs)
-
- def test_only_tenant_name_flow(self):
- flag = "--os-tenant-name " + DEFAULT_TENANT_NAME
- kwargs = {
- "auth_url": "",
- "tenant_id": "",
- "tenant_name": DEFAULT_TENANT_NAME,
- "username": "",
- "password": "",
- "region_name": ""
- }
- self._assert_password_auth(flag, kwargs)
-
- def test_only_username_flow(self):
- flag = "--os-username " + DEFAULT_USERNAME
- kwargs = {
- "auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
- "username": DEFAULT_USERNAME,
- "password": "",
- "region_name": ""
- }
- self._assert_password_auth(flag, kwargs)
-
- def test_only_password_flow(self):
- flag = "--os-password " + DEFAULT_PASSWORD
- kwargs = {
- "auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
- "username": "",
- "password": DEFAULT_PASSWORD,
- "region_name": ""
- }
- self._assert_password_auth(flag, kwargs)
-
- def test_only_region_name_flow(self):
- flag = "--os-region-name " + DEFAULT_REGION_NAME
- kwargs = {
- "auth_url": "",
- "tenant_id": "",
- "tenant_name": "",
- "username": "",
- "password": "",
- "region_name": DEFAULT_REGION_NAME
- }
- self._assert_password_auth(flag, kwargs)
-
-
-class TestShellTokenAuth(TestShell):
- def setUp(self):
- super(TestShellTokenAuth, self).setUp()
- env = {
- "OS_TOKEN": DEFAULT_TOKEN,
- "OS_URL": DEFAULT_SERVICE_URL,
- }
- self.orig_env, os.environ = os.environ, env.copy()
-
- def tearDown(self):
- super(TestShellTokenAuth, self).tearDown()
- os.environ = self.orig_env
-
- def test_default_auth(self):
- flag = ""
- kwargs = {
- "os_token": DEFAULT_TOKEN,
- "os_url": DEFAULT_SERVICE_URL
- }
- self._assert_token_auth(flag, kwargs)
-
- def test_empty_auth(self):
- os.environ = {}
- flag = ""
- kwargs = {
- "os_token": "",
- "os_url": ""
- }
- self._assert_token_auth(flag, kwargs)
-
-
-class TestShellCli(TestShell):
- def setUp(self):
- super(TestShellCli, self).setUp()
- env = {
- "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()
-
- def tearDown(self):
- super(TestShellCli, self).tearDown()
- os.environ = self.orig_env
-
- def test_shell_args(self):
- _shell = make_shell()
- with mock.patch("openstackclient.shell.OpenStackShell.initialize_app",
- self.app):
- fake_execute(_shell, "list user")
- self.app.assert_called_with(["list", "user"])
-
- def test_default_env(self):
- flag = ""
- kwargs = {
- "compute_api_version": DEFAULT_COMPUTE_API_VERSION,
- "identity_api_version": DEFAULT_IDENTITY_API_VERSION,
- "image_api_version": DEFAULT_IMAGE_API_VERSION,
- "volume_api_version": DEFAULT_VOLUME_API_VERSION
- }
- self._assert_cli(flag, kwargs)
-
- def test_empty_env(self):
- os.environ = {}
- flag = ""
- kwargs = {
- "compute_api_version": LIB_COMPUTE_API_VERSION,
- "identity_api_version": LIB_IDENTITY_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/utils.py b/tests/utils.py
deleted file mode 100644
index 3e24ff4a..00000000
--- a/tests/utils.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2012-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 os
-
-import fixtures
-import sys
-import testtools
-
-
-class TestCase(testtools.TestCase):
- def setUp(self):
- testtools.TestCase.setUp(self)
-
- if (os.environ.get("OS_STDOUT_NOCAPTURE") == "True" and
- os.environ.get("OS_STDOUT_NOCAPTURE") == "1"):
- stdout = self.useFixture(fixtures.StringStream("stdout")).stream
- self.useFixture(fixtures.MonkeyPatch("sys.stdout", stdout))
-
- if (os.environ.get("OS_STDERR_NOCAPTURE") == "True" and
- os.environ.get("OS_STDERR_NOCAPTURE") == "1"):
- stderr = self.useFixture(fixtures.StringStream("stderr")).stream
- self.useFixture(fixtures.MonkeyPatch("sys.stderr", stderr))
-
- # 2.6 doesn't have the assert dict equals so make sure that it exists
- if tuple(sys.version_info)[0:2] < (2, 7):
-
- def assertIsInstance(self, obj, cls, msg=None):
- """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
- default message
- """
- if not isinstance(obj, cls):
- standardMsg = '%s is not an instance of %r' % (obj, cls)
- self.fail(self._formatMessage(msg, standardMsg))
-
- def assertDictEqual(self, d1, d2, msg=None):
- # Simple version taken from 2.7
- self.assertIsInstance(d1, dict,
- 'First argument is not a dictionary')
- self.assertIsInstance(d2, dict,
- 'Second argument is not a dictionary')
- if d1 != d2:
- if msg:
- self.fail(msg)
- else:
- standardMsg = '%r != %r' % (d1, d2)
- self.fail(standardMsg)
diff --git a/tests/volume/__init__.py b/tests/volume/__init__.py
deleted file mode 100644
index ebf59b32..00000000
--- a/tests/volume/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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
deleted file mode 100644
index 8c60dd12..00000000
--- a/tests/volume/test_volume.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# 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)