summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-08-15 15:02:51 -0400
committerMichael Still <mikal@stillhq.com>2013-04-04 13:14:27 +1100
commit799a925c1f4a388c30a7f0d9e1ffe1b82e8ced9d (patch)
tree596812f9f17ca76741cfec8ca0899a99bd75a7b2 /nova/tests
parenta01f907cecc24c18cbe3d32921247125294dd2b9 (diff)
Move console scripts to entrypoints.
As part of the move of plugins to entrypoints, take advantage of the entrypoints based console scripts, which will make our command line scripts available for unittesting. Part of blueprint entrypoints-plugins Co-authored-by: Michael Still <mikal@stillhq.com> Change-Id: I5f17348b7b3cc896c92263dd518abb128757d81f
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/baremetal/test_nova_baremetal_deploy_helper.py14
-rw-r--r--nova/tests/baremetal/test_nova_baremetal_manage.py16
-rw-r--r--nova/tests/test_nova_manage.py51
3 files changed, 17 insertions, 64 deletions
diff --git a/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py b/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py
index 7ec7fd0fd..004fce060 100644
--- a/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py
+++ b/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py
@@ -16,29 +16,17 @@
# License for the specific language governing permissions and limitations
# under the License.
-import imp
import os
-import sys
import tempfile
import time
import mox
+from nova.cmd import baremetal_deploy_helper as bmdh
from nova import test
from nova.tests.baremetal.db import base as bm_db_base
from nova.virt.baremetal import db as bm_db
-TOPDIR = os.path.normpath(os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- os.pardir,
- os.pardir,
- os.pardir))
-BMDH_PATH = os.path.join(TOPDIR, 'bin', 'nova-baremetal-deploy-helper')
-
-sys.dont_write_bytecode = True
-bmdh = imp.load_source('bmdh', BMDH_PATH)
-sys.dont_write_bytecode = False
-
_PXECONF_DEPLOY = """
default deploy
diff --git a/nova/tests/baremetal/test_nova_baremetal_manage.py b/nova/tests/baremetal/test_nova_baremetal_manage.py
index 74e084113..6be63aac2 100644
--- a/nova/tests/baremetal/test_nova_baremetal_manage.py
+++ b/nova/tests/baremetal/test_nova_baremetal_manage.py
@@ -16,23 +16,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import imp
-import os
-import sys
-
+from nova.cmd import baremetal_manage as bm_man
from nova.tests.baremetal.db import base as bm_db_base
-TOPDIR = os.path.normpath(os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- os.pardir,
- os.pardir,
- os.pardir))
-BM_MAN_PATH = os.path.join(TOPDIR, 'bin', 'nova-baremetal-manage')
-
-sys.dont_write_bytecode = True
-bm_man = imp.load_source('bm_man', BM_MAN_PATH)
-sys.dont_write_bytecode = False
-
class BareMetalDbCommandsTestCase(bm_db_base.BMDBTestCase):
def setUp(self):
diff --git a/nova/tests/test_nova_manage.py b/nova/tests/test_nova_manage.py
index 349e9460f..3dc5cc5c2 100644
--- a/nova/tests/test_nova_manage.py
+++ b/nova/tests/test_nova_manage.py
@@ -15,11 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import imp
-import os
import StringIO
import sys
+from nova.cmd import manage
from nova import context
from nova import db
from nova import exception
@@ -27,22 +26,11 @@ from nova import test
from nova.tests.db import fakes as db_fakes
-TOPDIR = os.path.normpath(os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- os.pardir,
- os.pardir))
-NOVA_MANAGE_PATH = os.path.join(TOPDIR, 'bin', 'nova-manage')
-
-sys.dont_write_bytecode = True
-nova_manage = imp.load_source('nova_manage', NOVA_MANAGE_PATH)
-sys.dont_write_bytecode = False
-
-
class FixedIpCommandsTestCase(test.TestCase):
def setUp(self):
super(FixedIpCommandsTestCase, self).setUp()
db_fakes.stub_out_db_network_api(self.stubs)
- self.commands = nova_manage.FixedIpCommands()
+ self.commands = manage.FixedIpCommands()
def test_reserve(self):
self.commands.reserve('192.168.0.100')
@@ -51,9 +39,7 @@ class FixedIpCommandsTestCase(test.TestCase):
self.assertEqual(address['reserved'], True)
def test_reserve_nonexistent_address(self):
- self.assertRaises(SystemExit,
- self.commands.reserve,
- '55.55.55.55')
+ self.assertEqual(2, self.commands.reserve('55.55.55.55'))
def test_unreserve(self):
self.commands.unreserve('192.168.0.100')
@@ -62,16 +48,14 @@ class FixedIpCommandsTestCase(test.TestCase):
self.assertEqual(address['reserved'], False)
def test_unreserve_nonexistent_address(self):
- self.assertRaises(SystemExit,
- self.commands.unreserve,
- '55.55.55.55')
+ self.assertEqual(2, self.commands.unreserve('55.55.55.55'))
class FloatingIpCommandsTestCase(test.TestCase):
def setUp(self):
super(FloatingIpCommandsTestCase, self).setUp()
db_fakes.stub_out_db_network_api(self.stubs)
- self.commands = nova_manage.FloatingIpCommands()
+ self.commands = manage.FloatingIpCommands()
def test_address_to_hosts(self):
def assert_loop(result, expected):
@@ -111,7 +95,7 @@ class FloatingIpCommandsTestCase(test.TestCase):
class NetworkCommandsTestCase(test.TestCase):
def setUp(self):
super(NetworkCommandsTestCase, self).setUp()
- self.commands = nova_manage.NetworkCommands()
+ self.commands = manage.NetworkCommands()
self.net = {'id': 0,
'label': 'fake',
'injected': False,
@@ -292,8 +276,8 @@ class InstanceTypeCommandsTestCase(test.TestCase):
self.instance_type_name = ref["name"]
self.instance_type_id = ref["id"]
self.instance_type_flavorid = ref["flavorid"]
- self.set_key = nova_manage.InstanceTypeCommands().set_key
- self.unset_key = nova_manage.InstanceTypeCommands().unset_key
+ self.set_key = manage.InstanceTypeCommands().set_key
+ self.unset_key = manage.InstanceTypeCommands().unset_key
def tearDown(self):
db.instance_type_destroy(context.get_admin_context(),
@@ -361,7 +345,7 @@ class InstanceTypeCommandsTestCase(test.TestCase):
class ProjectCommandsTestCase(test.TestCase):
def setUp(self):
super(ProjectCommandsTestCase, self).setUp()
- self.commands = nova_manage.ProjectCommands()
+ self.commands = manage.ProjectCommands()
def test_quota(self):
output = StringIO.StringIO()
@@ -377,30 +361,25 @@ class ProjectCommandsTestCase(test.TestCase):
self.assertEquals((print_format in result), True)
def test_quota_update_invalid_key(self):
- self.assertRaises(SystemExit,
- self.commands.quota, 'admin', 'volumes1', '10'
- )
+ self.assertEqual(2, self.commands.quota('admin', 'volumes1', '10'))
class DBCommandsTestCase(test.TestCase):
def setUp(self):
super(DBCommandsTestCase, self).setUp()
- self.commands = nova_manage.DbCommands()
+ self.commands = manage.DbCommands()
def test_archive_deleted_rows_negative(self):
- self.assertRaises(SystemExit,
- self.commands.archive_deleted_rows, -1)
+ self.assertEqual(1, self.commands.archive_deleted_rows(-1))
class ServiceCommandsTestCase(test.TestCase):
def setUp(self):
super(ServiceCommandsTestCase, self).setUp()
- self.commands = nova_manage.ServiceCommands()
+ self.commands = manage.ServiceCommands()
def test_service_enable_invalid_params(self):
- self.assertRaises(SystemExit,
- self.commands.enable, 'nohost', 'noservice')
+ self.assertEqual(2, self.commands.enable('nohost', 'noservice'))
def test_service_disable_invalid_params(self):
- self.assertRaises(SystemExit,
- self.commands.disable, 'nohost', 'noservice')
+ self.assertEqual(2, self.commands.disable('nohost', 'noservice'))