diff --git a/nova/tests/hyperv/hypervutils.py b/nova/tests/hyperv/hypervutils.py index 59f7e50f2..b71e60229 100644 --- a/nova/tests/hyperv/hypervutils.py +++ b/nova/tests/hyperv/hypervutils.py @@ -87,7 +87,7 @@ class HyperVUtils(object): % (path, ret_val)) def _check_job_status(self, jobpath): - """Poll WMI job state for completion""" + """Poll WMI job state for completion.""" job_wmi_path = jobpath.replace('\\', '/') job = wmi.WMI(moniker=job_wmi_path) diff --git a/nova/tests/hyperv/mockproxy.py b/nova/tests/hyperv/mockproxy.py index d1f3b57d2..513422c13 100644 --- a/nova/tests/hyperv/mockproxy.py +++ b/nova/tests/hyperv/mockproxy.py @@ -49,7 +49,7 @@ def serialize_obj(obj): def serialize_args(*args, **kwargs): - """Workaround for float string conversion issues in Python 2.6""" + """Workaround for float string conversion issues in Python 2.6.""" return serialize_obj((args, kwargs)) diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py index 3c7b462d0..652893662 100644 --- a/nova/tests/scheduler/fakes.py +++ b/nova/tests/scheduler/fakes.py @@ -108,14 +108,14 @@ class FakeHostState(host_manager.HostState): class FakeInstance(object): def __init__(self, context=None, params=None, type_name='m1.tiny'): - """Create a test instance. Returns uuid""" + """Create a test instance. Returns uuid.""" self.context = context i = self._create_fake_instance(params, type_name=type_name) self.uuid = i['uuid'] def _create_fake_instance(self, params=None, type_name='m1.tiny'): - """Create a test instance""" + """Create a test instance.""" if not params: params = {} diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index 4d7fb02ec..5d8e8236b 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -216,7 +216,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertRaises(exception.NovaException, sched._max_attempts) def test_retry_disabled(self): - """Retry info should not get populated when re-scheduling is off""" + # Retry info should not get populated when re-scheduling is off. self.flags(scheduler_max_attempts=1) sched = fakes.FakeFilterScheduler() @@ -231,7 +231,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertFalse("retry" in filter_properties) def test_retry_attempt_one(self): - """Test retry logic on initial scheduling attempt""" + # Test retry logic on initial scheduling attempt. self.flags(scheduler_max_attempts=2) sched = fakes.FakeFilterScheduler() @@ -246,7 +246,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertEqual(1, num_attempts) def test_retry_attempt_two(self): - """Test retry logic when re-scheduling""" + # Test retry logic when re-scheduling. self.flags(scheduler_max_attempts=2) sched = fakes.FakeFilterScheduler() @@ -263,7 +263,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertEqual(2, num_attempts) def test_retry_exceeded_max_attempts(self): - """Test for necessary explosion when max retries is exceeded""" + # Test for necessary explosion when max retries is exceeded. self.flags(scheduler_max_attempts=2) sched = fakes.FakeFilterScheduler() @@ -290,7 +290,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertEqual([host, node], hosts[0]) def test_post_select_populate(self): - """Test addition of certain filter props after a node is selected""" + # Test addition of certain filter props after a node is selected. retry = {'hosts': [], 'num_attempts': 1} filter_properties = {'retry': retry} sched = fakes.FakeFilterScheduler() @@ -306,7 +306,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): self.assertEqual({'vcpus': 5}, host_state.limits) def test_prep_resize_post_populates_retry(self): - """Prep resize should add a ('host', 'node') entry to the retry dict""" + # Prep resize should add a ('host', 'node') entry to the retry dict. sched = fakes.FakeFilterScheduler() image = 'image' diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index b08da6baa..7314c7cc6 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -38,7 +38,7 @@ class TestFilter(filters.BaseHostFilter): class TestBogusFilter(object): - """Class that doesn't inherit from BaseHostFilter""" + """Class that doesn't inherit from BaseHostFilter.""" pass @@ -928,7 +928,7 @@ class HostFiltersTestCase(test.TestCase): self.assertFalse(filt_cls.host_passes(host, filter_properties)) def test_json_filter_happy_day(self): - """Test json filter more thoroughly""" + # Test json filter more thoroughly. filt_cls = self.class_map['JsonFilter']() raw = ['and', '$capabilities.enabled', @@ -1246,14 +1246,14 @@ class HostFiltersTestCase(test.TestCase): self.assertFalse(filt_cls.host_passes(host, request)) def test_retry_filter_disabled(self): - """Test case where retry/re-scheduling is disabled""" + # Test case where retry/re-scheduling is disabled. filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'node1', {}) filter_properties = {} self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_pass(self): - """Node not previously tried""" + # Node not previously tried. filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'nodeX', {}) retry = dict(num_attempts=2, @@ -1264,7 +1264,7 @@ class HostFiltersTestCase(test.TestCase): self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_fail(self): - """Node was already tried""" + # Node was already tried. filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'node1', {}) retry = dict(num_attempts=1, diff --git a/nova/tests/scheduler/test_host_manager.py b/nova/tests/scheduler/test_host_manager.py index c1236a7fe..ae7774bac 100644 --- a/nova/tests/scheduler/test_host_manager.py +++ b/nova/tests/scheduler/test_host_manager.py @@ -38,7 +38,7 @@ class FakeFilterClass2(filters.BaseHostFilter): class HostManagerTestCase(test.TestCase): - """Test case for HostManager class""" + """Test case for HostManager class.""" def setUp(self): super(HostManagerTestCase, self).setUp() @@ -159,7 +159,7 @@ class HostManagerTestCase(test.TestCase): self._verify_result(info, result) def test_get_filtered_hosts_with_ignore_and_force(self): - """Ensure ignore_hosts processed before force_hosts in host filters""" + # Ensure ignore_hosts processed before force_hosts in host filters. fake_properties = {'force_hosts': ['fake_host3', 'fake_host1'], 'ignore_hosts': ['fake_host1']} @@ -268,7 +268,7 @@ class HostManagerTestCase(test.TestCase): class HostStateTestCase(test.TestCase): - """Test case for HostState class""" + """Test case for HostState class.""" # update_from_compute_node() and consume_from_instance() are tested # in HostManagerTestCase.test_get_all_host_states() diff --git a/nova/tests/scheduler/test_multi_scheduler.py b/nova/tests/scheduler/test_multi_scheduler.py index ee9e0bbd3..5642c4e17 100644 --- a/nova/tests/scheduler/test_multi_scheduler.py +++ b/nova/tests/scheduler/test_multi_scheduler.py @@ -45,7 +45,7 @@ class FakeDefaultScheduler(driver.Scheduler): class MultiDriverTestCase(test_scheduler.SchedulerTestCase): - """Test case for multi driver""" + """Test case for multi driver.""" driver_cls = multi.MultiScheduler diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 9b9f85925..ceea74e70 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -40,7 +40,7 @@ from nova.tests.scheduler import fakes class SchedulerManagerTestCase(test.TestCase): - """Test case for scheduler manager""" + """Test case for scheduler manager.""" manager_cls = manager.SchedulerManager driver_cls = driver.Scheduler @@ -268,7 +268,7 @@ class SchedulerManagerTestCase(test.TestCase): class SchedulerTestCase(test.TestCase): - """Test case for base scheduler driver class""" + """Test case for base scheduler driver class.""" # So we can subclass this test and re-use tests if we need. driver_cls = driver.Scheduler @@ -325,7 +325,7 @@ class SchedulerTestCase(test.TestCase): 'task_state': ''} def test_live_migration_basic(self): - """Test basic schedule_live_migration functionality""" + # Test basic schedule_live_migration functionality. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(self.driver, '_live_migration_common_check') @@ -359,7 +359,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_all_checks_pass(self): - """Test live migration when all checks pass.""" + # Test live migration when all checks pass. self.mox.StubOutWithMock(servicegroup.API, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -422,7 +422,7 @@ class SchedulerTestCase(test.TestCase): self.assertEqual(result, None) def test_live_migration_instance_not_running(self): - """The instance given by instance_id is not running.""" + # The instance given by instance_id is not running. dest = 'fake_host2' block_migration = False @@ -437,7 +437,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_compute_src_not_exist(self): - """Raise exception when src compute node is does not exist.""" + # Raise exception when src compute node is does not exist. self.mox.StubOutWithMock(servicegroup.API, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -460,7 +460,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_compute_src_not_alive(self): - """Raise exception when src compute node is not alive.""" + # Raise exception when src compute node is not alive. self.mox.StubOutWithMock(servicegroup.API, 'service_is_up') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -483,7 +483,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_compute_dest_not_alive(self): - """Raise exception when dest compute node is not alive.""" + # Raise exception when dest compute node is not alive. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -508,7 +508,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_dest_check_service_same_host(self): - """Confirms exception raises in case dest and src is same host.""" + # Confirms exception raises in case dest and src is same host. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -532,7 +532,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=False) def test_live_migration_dest_check_service_lack_memory(self): - """Confirms exception raises when dest doesn't have enough memory.""" + # Confirms exception raises when dest doesn't have enough memory. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(db, 'service_get_all_compute_by_host') @@ -563,7 +563,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_different_hypervisor_type_raises(self): - """Confirm live_migration to hypervisor of different type raises""" + # Confirm live_migration to hypervisor of different type raises. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(rpc, 'queue_get_for') @@ -595,7 +595,7 @@ class SchedulerTestCase(test.TestCase): disk_over_commit=disk_over_commit) def test_live_migration_dest_hypervisor_version_older_raises(self): - """Confirm live migration to older hypervisor raises""" + # Confirm live migration to older hypervisor raises. self.mox.StubOutWithMock(self.driver, '_live_migration_src_check') self.mox.StubOutWithMock(self.driver, '_live_migration_dest_check') self.mox.StubOutWithMock(rpc, 'queue_get_for') @@ -654,7 +654,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase): class SchedulerDriverModuleTestCase(test.TestCase): - """Test case for scheduler driver module methods""" + """Test case for scheduler driver module methods.""" def setUp(self): super(SchedulerDriverModuleTestCase, self).setUp() diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index 0835df51d..829a98334 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -16,7 +16,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Unit tests for the API endpoint""" +"""Unit tests for the API endpoint.""" import random import StringIO @@ -45,13 +45,13 @@ from nova.tests import matchers class FakeHttplibSocket(object): - """a fake socket implementation for httplib.HTTPResponse, trivial""" + """a fake socket implementation for httplib.HTTPResponse, trivial.""" def __init__(self, response_string): self.response_string = response_string self._buffer = StringIO.StringIO(response_string) def makefile(self, _mode, _other): - """Returns the socket's internal buffer""" + """Returns the socket's internal buffer.""" return self._buffer @@ -91,12 +91,12 @@ class FakeHttplibConnection(object): return self.sock.response_string def close(self): - """Required for compatibility with boto/tornado""" + """Required for compatibility with boto/tornado.""" pass class XmlConversionTestCase(test.TestCase): - """Unit test api xml conversion""" + """Unit test api xml conversion.""" def test_number_conversion(self): conv = ec2utils._try_convert self.assertEqual(conv('None'), None) @@ -212,7 +212,7 @@ class Ec2utilsTestCase(test.TestCase): class ApiEc2TestCase(test.TestCase): - """Unit test for the cloud controller on an EC2 API""" + """Unit test for the cloud controller on an EC2 API.""" def setUp(self): super(ApiEc2TestCase, self).setUp() self.host = '127.0.0.1' @@ -225,7 +225,7 @@ class ApiEc2TestCase(test.TestCase): self.useFixture(fixtures.FakeLogger('boto')) def expect_http(self, host=None, is_secure=False, api_version=None): - """Returns a new EC2 connection""" + """Returns a new EC2 connection.""" self.ec2 = boto.connect_ec2( aws_access_key_id='fake', aws_secret_access_key='fake', @@ -281,7 +281,7 @@ class ApiEc2TestCase(test.TestCase): self.assertEqual(self.ec2.get_all_instances(), []) def test_terminate_invalid_instance(self): - """Attempt to terminate an invalid instance""" + # Attempt to terminate an invalid instance. self.expect_http() self.mox.ReplayAll() self.assertRaises(boto_exc.EC2ResponseError, @@ -318,7 +318,7 @@ class ApiEc2TestCase(test.TestCase): self.fail('Exception not raised.') def test_get_all_security_groups(self): - """Test that we can retrieve security groups""" + # Test that we can retrieve security groups. self.expect_http() self.mox.ReplayAll() @@ -328,7 +328,7 @@ class ApiEc2TestCase(test.TestCase): self.assertEquals(rv[0].name, 'default') def test_create_delete_security_group(self): - """Test that we can create a security group""" + # Test that we can create a security group. self.expect_http() self.mox.ReplayAll() diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 0aaa42a11..48ba00368 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -17,7 +17,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Unit tests for the DB API""" +"""Unit tests for the DB API.""" import datetime import uuid as stdlib_uuid @@ -114,7 +114,7 @@ class DbApiTestCase(test.TestCase): self.assertEqual(2, len(result)) def test_instance_get_all_by_filters_regex_unsupported_db(self): - """Ensure that the 'LIKE' operator is used for unsupported dbs.""" + # Ensure that the 'LIKE' operator is used for unsupported dbs. self.flags(sql_connection="notdb://") self.create_instances_with_args(display_name='test1') self.create_instances_with_args(display_name='test.*') @@ -321,7 +321,7 @@ class DbApiTestCase(test.TestCase): inst['uuid'], 'vm_state', [None, 'disable'], 'run') def test_instance_update_with_instance_uuid(self): - """test instance_update() works when an instance UUID is passed """ + # test instance_update() works when an instance UUID is passed. ctxt = context.get_admin_context() # Create an instance with some metadata @@ -428,7 +428,7 @@ class DbApiTestCase(test.TestCase): self.assertEquals("needscoffee", new_ref["vm_state"]) def test_instance_update_with_extra_specs(self): - """Ensure _extra_specs are returned from _instance_update""" + # Ensure _extra_specs are returned from _instance_update. ctxt = context.get_admin_context() # create a flavor @@ -463,7 +463,7 @@ class DbApiTestCase(test.TestCase): self.assertEquals(spec, new_ref['extra_specs']) def test_instance_fault_create(self): - """Ensure we can create an instance fault""" + # Ensure we can create an instance fault. ctxt = context.get_admin_context() uuid = str(stdlib_uuid.uuid4()) @@ -481,7 +481,7 @@ class DbApiTestCase(test.TestCase): self.assertEqual(404, faults[uuid][0]['code']) def test_instance_fault_get_by_instance(self): - """ensure we can retrieve an instance fault by instance UUID """ + # ensure we can retrieve an instance fault by instance UUID. ctxt = context.get_admin_context() instance1 = db.instance_create(ctxt, {}) instance2 = db.instance_create(ctxt, {}) @@ -530,7 +530,7 @@ class DbApiTestCase(test.TestCase): self.assertEqual(instance_faults, expected) def test_instance_faults_get_by_instance_uuids_no_faults(self): - """None should be returned when no faults exist""" + # None should be returned when no faults exist. ctxt = context.get_admin_context() instance1 = db.instance_create(ctxt, {}) instance2 = db.instance_create(ctxt, {}) diff --git a/nova/tests/test_filters.py b/nova/tests/test_filters.py index 546b13180..13fd122c8 100644 --- a/nova/tests/test_filters.py +++ b/nova/tests/test_filters.py @@ -52,7 +52,7 @@ class FiltersTestCase(test.TestCase): self.assertEqual(list(result), ['obj1', 'obj3']) def test_filter_all_recursive_yields(self): - """Test filter_all() allows generators from previous filter_all()s.""" + # Test filter_all() allows generators from previous filter_all()s. # filter_all() yields results. We want to make sure that we can # call filter_all() with generators returned from previous calls # to filter_all(). diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py index 51576a8ea..4a136cf13 100644 --- a/nova/tests/test_instance_types.py +++ b/nova/tests/test_instance_types.py @@ -30,9 +30,9 @@ LOG = logging.getLogger(__name__) class InstanceTypeTestCase(test.TestCase): - """Test cases for instance type code""" + """Test cases for instance type code.""" def _generate_name(self): - """return a name not in the DB""" + """return a name not in the DB.""" nonexistent_flavor = str(int(time.time())) flavors = instance_types.get_all_types() while nonexistent_flavor in flavors: @@ -41,7 +41,7 @@ class InstanceTypeTestCase(test.TestCase): return nonexistent_flavor def _generate_flavorid(self): - """return a flavorid not in the DB""" + """return a flavorid not in the DB.""" nonexistent_flavor = 2700 flavor_ids = [value["id"] for key, value in instance_types.get_all_types().iteritems()] @@ -51,11 +51,11 @@ class InstanceTypeTestCase(test.TestCase): return nonexistent_flavor def _existing_flavor(self): - """return first instance type name""" + """return first instance type name.""" return instance_types.get_all_types().keys()[0] def test_instance_type_create(self): - """Ensure instance types can be created""" + # Ensure instance types can be created. name = 'Instance create test' flavor_id = '512' @@ -79,7 +79,7 @@ class InstanceTypeTestCase(test.TestCase): 'instance type was not created') def test_instance_type_create_then_delete(self): - """Ensure instance types can be created""" + # Ensure instance types can be created. name = 'Small Flavor' flavorid = 'flavor1' @@ -136,21 +136,21 @@ class InstanceTypeTestCase(test.TestCase): self.assertEqual(inst_type['rxtx_factor'], 9.9) def test_instance_type_create_with_special_characters(self): - """Ensure instance types raises InvalidInput for invalid characters""" + # Ensure instance types raises InvalidInput for invalid characters. name = "foo.bar!@#$%^-test_name" flavorid = "flavor1" self.assertRaises(exception.InvalidInput, instance_types.create, name, 256, 1, 120, 100, flavorid) def test_get_all_instance_types(self): - """Ensures that all instance types can be retrieved""" + # Ensures that all instance types can be retrieved. session = sql_session.get_session() total_instance_types = session.query(models.InstanceTypes).count() inst_types = instance_types.get_all_types() self.assertEqual(total_instance_types, len(inst_types)) def test_invalid_create_args_should_fail(self): - """Ensures that instance type creation fails with invalid args""" + # Ensures that instance type creation fails with invalid args. invalid_sigs = [ (('Zero memory', 0, 1, 10, 20, 'flavor1'), {}), (('Negative memory', -256, 1, 10, 20, 'flavor1'), {}), @@ -177,13 +177,13 @@ class InstanceTypeTestCase(test.TestCase): instance_types.create, *args, **kwargs) def test_non_existent_inst_type_shouldnt_delete(self): - """Ensures that instance type creation fails with invalid args""" + # Ensures that instance type creation fails with invalid args. self.assertRaises(exception.InstanceTypeNotFoundByName, instance_types.destroy, 'unknown_flavor') def test_duplicate_names_fail(self): - """Ensures that name duplicates raise InstanceTypeCreateFailed""" + # Ensures that name duplicates raise InstanceTypeCreateFailed. name = 'some_name' instance_types.create(name, 256, 1, 120, 200, 'flavor1') self.assertRaises(exception.InstanceTypeExists, @@ -191,7 +191,7 @@ class InstanceTypeTestCase(test.TestCase): name, 256, 1, 120, 200, 'flavor2') def test_duplicate_flavorids_fail(self): - """Ensures that flavorid duplicates raise InstanceTypeCreateFailed""" + # Ensures that flavorid duplicates raise InstanceTypeCreateFailed. flavorid = 'flavor1' instance_types.create('name one', 256, 1, 120, 200, flavorid) self.assertRaises(exception.InstanceTypeIdExists, @@ -199,12 +199,12 @@ class InstanceTypeTestCase(test.TestCase): 'name two', 256, 1, 120, 200, flavorid) def test_will_not_destroy_with_no_name(self): - """Ensure destroy said path of no name raises error""" + # Ensure destroy said path of no name raises error. self.assertRaises(exception.InstanceTypeNotFoundByName, instance_types.destroy, None) def test_will_not_get_bad_default_instance_type(self): - """ensures error raised on bad default instance type""" + # ensures error raised on bad default instance type. self.flags(default_instance_type='unknown_flavor') self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_default_instance_type) @@ -216,28 +216,28 @@ class InstanceTypeTestCase(test.TestCase): self.assertEqual(default_instance_type, fetched) def test_will_not_get_instance_type_by_unknown_id(self): - """Ensure get by name returns default flavor with no name""" + # Ensure get by name returns default flavor with no name. self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_instance_type, 10000) def test_will_not_get_instance_type_with_bad_id(self): - """Ensure get by name returns default flavor with bad name""" + # Ensure get by name returns default flavor with bad name. self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_instance_type, 'asdf') def test_instance_type_get_by_None_name_returns_default(self): - """Ensure get by name returns default flavor with no name""" + # Ensure get by name returns default flavor with no name. default = instance_types.get_default_instance_type() actual = instance_types.get_instance_type_by_name(None) self.assertEqual(default, actual) def test_will_not_get_instance_type_with_bad_name(self): - """Ensure get by name returns default flavor with bad name""" + # Ensure get by name returns default flavor with bad name. self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_instance_type_by_name, 10000) def test_will_not_get_instance_by_unknown_flavor_id(self): - """Ensure get by flavor raises error with wrong flavorid""" + # Ensure get by flavor raises error with wrong flavorid. self.assertRaises(exception.FlavorNotFound, instance_types.get_instance_type_by_flavor_id, 'unknown_flavor') @@ -249,7 +249,7 @@ class InstanceTypeTestCase(test.TestCase): self.assertEqual(default_instance_type, fetched) def test_can_read_deleted_types_using_flavor_id(self): - """Ensure deleted instance types can be read when querying flavor_id""" + # Ensure deleted instance types can be read when querying flavor_id. inst_type_name = "test" inst_type_flavor_id = "test1" @@ -280,7 +280,7 @@ class InstanceTypeTestCase(test.TestCase): self.assertEqual("instance_type1_redo", instance_type["name"]) def test_will_list_deleted_type_for_active_instance(self): - """Ensure deleted instance types with active instances can be read""" + # Ensure deleted instance types with active instances can be read. ctxt = context.get_admin_context() inst_type = instance_types.create("test", 256, 1, 120, 100, "test1") @@ -299,7 +299,7 @@ class InstanceTypeTestCase(test.TestCase): class InstanceTypeFilteringTest(test.TestCase): - """Test cases for the filter option available for instance_type_get_all""" + """Test cases for the filter option available for instance_type_get_all.""" def setUp(self): super(InstanceTypeFilteringTest, self).setUp() self.context = context.get_admin_context() @@ -317,19 +317,19 @@ class InstanceTypeFilteringTest(test.TestCase): self.assertFilterResults(filters, expected) def test_min_memory_mb_filter(self): - """Exclude tiny instance which is 512 MB""" + # Exclude tiny instance which is 512 MB. filters = dict(min_memory_mb=513) expected = ['m1.large', 'm1.medium', 'm1.small', 'm1.xlarge'] self.assertFilterResults(filters, expected) def test_min_root_gb_filter(self): - """Exclude everything but large and xlarge which have >= 80 GB""" + # Exclude everything but large and xlarge which have >= 80 GB. filters = dict(min_root_gb=80) expected = ['m1.large', 'm1.xlarge'] self.assertFilterResults(filters, expected) def test_min_memory_mb_AND_root_gb_filter(self): - """Exclude everything but large and xlarge which have >= 80 GB""" + # Exclude everything but large and xlarge which have >= 80 GB. filters = dict(min_memory_mb=16384, min_root_gb=80) expected = ['m1.xlarge'] self.assertFilterResults(filters, expected) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index bd6816d71..f167bfef8 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -473,7 +473,7 @@ class CacheConcurrencyTestCase(test.TestCase): super(CacheConcurrencyTestCase, self).tearDown() def test_same_fname_concurrency(self): - """Ensures that the same fname cache runs at a sequentially""" + # Ensures that the same fname cache runs at a sequentially. backend = imagebackend.Backend(False) wait1 = eventlet.event.Event() done1 = eventlet.event.Event() @@ -507,7 +507,7 @@ class CacheConcurrencyTestCase(test.TestCase): thr2.wait() def test_different_fname_concurrency(self): - """Ensures that two different fname caches are concurrent""" + # Ensures that two different fname caches are concurrent. backend = imagebackend.Backend(False) wait1 = eventlet.event.Event() done1 = eventlet.event.Event() @@ -2043,7 +2043,7 @@ class LibvirtConnTestCase(test.TestCase): db.instance_destroy(user_context, instance_ref['uuid']) def test_ensure_filtering_rules_for_instance_timeout(self): - """ensure_filtering_fules_for_instance() finishes with timeout.""" + # ensure_filtering_fules_for_instance() finishes with timeout. # Preparing mocks def fake_none(self, *args): return @@ -2288,7 +2288,7 @@ class LibvirtConnTestCase(test.TestCase): self.context, instance_ref, dest_check_data) def test_live_migration_raises_exception(self): - """Confirms recover method is called when exceptions are raised.""" + # Confirms recover method is called when exceptions are raised. # Preparing data self.compute = importutils.import_object(CONF.compute_manager) instance_dict = {'host': 'fake', @@ -2933,7 +2933,7 @@ class LibvirtConnTestCase(test.TestCase): conn._destroy(instance) def test_available_least_handles_missing(self): - """Ensure destroy calls managedSaveRemove for saved instance""" + # Ensure destroy calls managedSaveRemove for saved instance. conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) def list_instances(): @@ -3424,7 +3424,7 @@ class HostStateTestCase(test.TestCase): instance_caps = [("x86_64", "kvm", "hvm"), ("i686", "kvm", "hvm")] class FakeConnection(object): - """Fake connection object""" + """Fake connection object.""" def get_vcpu_total(self): return 1 @@ -3936,7 +3936,7 @@ class NWFilterTestCase(test.TestCase): 'instance_type_id': 1}) def _create_instance_type(self, params=None): - """Create a test instance""" + """Create a test instance.""" if not params: params = {} @@ -4274,7 +4274,7 @@ class LibvirtDriverTestCase(test.TestCase): fake.FakeVirtAPI(), read_only=True) def _create_instance(self, params=None): - """Create a test instance""" + """Create a test instance.""" if not params: params = {} @@ -4630,14 +4630,14 @@ class LibvirtVolumeUsageTestCase(test.TestCase): class LibvirtNonblockingTestCase(test.TestCase): - """Test libvirt_nonblocking option""" + """Test libvirt_nonblocking option.""" def setUp(self): super(LibvirtNonblockingTestCase, self).setUp() self.flags(libvirt_nonblocking=True, libvirt_uri="test:///default") def test_connection_to_primitive(self): - """Test bug 962840""" + # Test bug 962840. import nova.virt.libvirt.driver as libvirt_driver connection = libvirt_driver.LibvirtDriver('') jsonutils.to_primitive(connection._conn, convert_instances=True) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index 9badfb61a..750326592 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -77,7 +77,7 @@ def _have_mysql(): class TestMigrations(test.TestCase): - """Test sqlalchemy-migrate migrations""" + """Test sqlalchemy-migrate migrations.""" DEFAULT_CONFIG_FILE = os.path.join(os.path.dirname(__file__), 'test_migrations.conf') @@ -211,9 +211,7 @@ class TestMigrations(test.TestCase): self.fail("Shouldn't have connected") def test_mysql_innodb(self): - """ - Test that table creation on mysql only builds InnoDB tables - """ + # Test that table creation on mysql only builds InnoDB tables if not _have_mysql(): self.skipTest("mysql not available") # add this to the global lists to make reset work with it, it's removed diff --git a/nova/tests/test_nova_rootwrap.py b/nova/tests/test_nova_rootwrap.py index df7b88f2c..1029e0c2c 100644 --- a/nova/tests/test_nova_rootwrap.py +++ b/nova/tests/test_nova_rootwrap.py @@ -109,7 +109,7 @@ class RootwrapTestCase(test.TestCase): p.wait() def test_KillFilter_no_raise(self): - """Makes sure ValueError from bug 926412 is gone""" + # Makes sure ValueError from bug 926412 is gone. f = filters.KillFilter("root", "") # Providing anything other than kill should be False usercmd = ['notkill', 999999] @@ -119,7 +119,7 @@ class RootwrapTestCase(test.TestCase): self.assertFalse(f.match(usercmd)) def test_KillFilter_deleted_exe(self): - """Makes sure deleted exe's are killed correctly""" + # Makes sure deleted exe's are killed correctly. # See bug #967931. def fake_readlink(blah): return '/bin/commandddddd (deleted)' diff --git a/nova/tests/test_plugin_api_extensions.py b/nova/tests/test_plugin_api_extensions.py index a40dd3276..77985854a 100644 --- a/nova/tests/test_plugin_api_extensions.py +++ b/nova/tests/test_plugin_api_extensions.py @@ -57,7 +57,7 @@ class MockEntrypoint(pkg_resources.EntryPoint): class APITestCase(test.TestCase): - """Test case for the plugin api extension interface""" + """Test case for the plugin api extension interface.""" def test_add_extension(self): def mock_load(_s): return TestPluginClass() diff --git a/nova/tests/test_powervm.py b/nova/tests/test_powervm.py index 3c944e170..68795e22f 100644 --- a/nova/tests/test_powervm.py +++ b/nova/tests/test_powervm.py @@ -162,7 +162,7 @@ class PowerVMDriverTestCase(test.TestCase): self.assertEqual(state, power_state.RUNNING) def test_spawn_cleanup_on_fail(self): - """Verify on a failed spawn, we get the original exception raised""" + # Verify on a failed spawn, we get the original exception raised. # helper function def raise_(ex): raise ex diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 2e2011a74..148ff247c 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -265,7 +265,7 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase): 'dev/sd') def test_attach_volume(self): - """This shows how to test Ops classes' methods.""" + # This shows how to test Ops classes' methods. stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests) conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False) instance = db.instance_create(self.context, self.instance_values) @@ -281,7 +281,7 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase): self.assertEqual(vm_ref, vm) def test_attach_volume_raise_exception(self): - """This shows how to test when exceptions are raised.""" + # This shows how to test when exceptions are raised. stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeFailedTests) conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False) @@ -636,7 +636,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): self.assertTrue(instance['architecture']) def test_spawn_empty_dns(self): - """Test spawning with an empty dns list""" + # Test spawning with an empty dns list. self._test_spawn(IMAGE_VHD, None, None, os_type="linux", architecture="x86-64", empty_dns=True) @@ -858,7 +858,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): str(3 * 10 * 1024)) def test_spawn_injected_files(self): - """Test spawning with injected_files""" + # Test spawning with injected_files. actual_injected_files = [] def fake_inject_file(self, method, args): @@ -1340,7 +1340,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase): network_info, image_meta, resize_instance=False) def test_migrate_no_auto_disk_config_no_resize_down(self): - """Resize down should fail when auto_disk_config not set""" + # Resize down should fail when auto_disk_config not set. instance_values = self.instance_values instance_values['root_gb'] = 40 instance_values['auto_disk_config'] = False @@ -1358,7 +1358,7 @@ class XenAPIImageTypeTestCase(test.TestCase): """Test ImageType class.""" def test_to_string(self): - """Can convert from type id to type string.""" + # Can convert from type id to type string. self.assertEquals( vm_utils.ImageType.to_string(vm_utils.ImageType.KERNEL), vm_utils.ImageType.KERNEL_STR) @@ -1439,23 +1439,23 @@ class XenAPIDetermineIsPVTestCase(test.TestCase): class CompareVersionTestCase(test.TestCase): def test_less_than(self): - """Test that cmp_version compares a as less than b""" + # Test that cmp_version compares a as less than b. self.assertTrue(vmops.cmp_version('1.2.3.4', '1.2.3.5') < 0) def test_greater_than(self): - """Test that cmp_version compares a as greater than b""" + # Test that cmp_version compares a as greater than b. self.assertTrue(vmops.cmp_version('1.2.3.5', '1.2.3.4') > 0) def test_equal(self): - """Test that cmp_version compares a as equal to b""" + # Test that cmp_version compares a as equal to b. self.assertTrue(vmops.cmp_version('1.2.3.4', '1.2.3.4') == 0) def test_non_lexical(self): - """Test that cmp_version compares non-lexically""" + # Test that cmp_version compares non-lexically. self.assertTrue(vmops.cmp_version('1.2.3.10', '1.2.3.4') > 0) def test_length(self): - """Test that cmp_version compares by length as last resort""" + # Test that cmp_version compares by length as last resort. self.assertTrue(vmops.cmp_version('1.2.3', '1.2.3.4') < 0) @@ -1619,7 +1619,7 @@ class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase): @stub_vm_utils_with_vdi_attached_here def test_instance_auto_disk_config_doesnt_pass_fail_safes(self): - """Should not partition unless fail safes pass""" + # Should not partition unless fail safes pass. self.instance_values['auto_disk_config'] = True def fake_get_partitions(dev): @@ -1645,7 +1645,7 @@ class XenAPIAutoDiskConfigTestCase(stubs.XenAPITestBase): class XenAPIGenerateLocal(stubs.XenAPITestBase): - """Test generating of local disks, like swap and ephemeral""" + """Test generating of local disks, like swap and ephemeral.""" def setUp(self): super(XenAPIGenerateLocal, self).setUp() self.flags(xenapi_connection_url='test_url', @@ -1697,7 +1697,7 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase): self.assertTrue(self.called) def test_generate_swap(self): - """Test swap disk generation.""" + # Test swap disk generation. instance = db.instance_create(self.context, self.instance_values) instance = db.instance_update(self.context, instance['uuid'], {'instance_type_id': 5}) @@ -1714,7 +1714,7 @@ class XenAPIGenerateLocal(stubs.XenAPITestBase): self.assertCalled(instance) def test_generate_ephemeral(self): - """Test ephemeral disk generation.""" + # Test ephemeral disk generation. instance = db.instance_create(self.context, self.instance_values) instance = db.instance_update(self.context, instance['uuid'], {'instance_type_id': 4}) @@ -2136,7 +2136,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase): class XenAPISRSelectionTestCase(stubs.XenAPITestBase): """Unit tests for testing we find the right SR.""" def test_safe_find_sr_raise_exception(self): - """Ensure StorageRepositoryNotFound is raise when wrong filter.""" + # Ensure StorageRepositoryNotFound is raise when wrong filter. self.flags(sr_matching_filter='yadayadayada') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass', @@ -2145,7 +2145,7 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBase): vm_utils.safe_find_sr, session) def test_safe_find_sr_local_storage(self): - """Ensure the default local-storage is found.""" + # Ensure the default local-storage is found. self.flags(sr_matching_filter='other-config:i18n-key=local-storage') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass', @@ -2162,7 +2162,7 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBase): self.assertEqual(local_sr, expected) def test_safe_find_sr_by_other_criteria(self): - """Ensure the SR is found when using a different filter.""" + # Ensure the SR is found when using a different filter. self.flags(sr_matching_filter='other-config:my_fake_sr=true') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass', @@ -2176,7 +2176,7 @@ class XenAPISRSelectionTestCase(stubs.XenAPITestBase): self.assertEqual(local_sr, expected) def test_safe_find_sr_default(self): - """Ensure the default SR is found regardless of other-config.""" + # Ensure the default SR is found regardless of other-config. self.flags(sr_matching_filter='default-sr:true') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass', @@ -2283,7 +2283,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): matchers.DictMatches(result['metadetails'])) def test_join_slave(self): - """Ensure join_slave gets called when the request gets to master.""" + # Ensure join_slave gets called when the request gets to master. def fake_join_slave(id, compute_uuid, host, url, user, password): fake_join_slave.called = True self.stubs.Set(self.conn._pool, "_join_slave", fake_join_slave) @@ -2338,7 +2338,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): self.context, result, "test_host") def test_remove_slave(self): - """Ensure eject slave gets called.""" + # Ensure eject slave gets called. def fake_eject_slave(id, compute_uuid, host_uuid): fake_eject_slave.called = True self.stubs.Set(self.conn._pool, "_eject_slave", fake_eject_slave) @@ -2350,7 +2350,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): self.assertTrue(fake_eject_slave.called) def test_remove_master_solo(self): - """Ensure metadata are cleared after removal.""" + # Ensure metadata are cleared after removal. def fake_clear_pool(id): fake_clear_pool.called = True self.stubs.Set(self.conn._pool, "_clear_pool", fake_clear_pool) @@ -2365,7 +2365,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): matchers.DictMatches(result['metadetails'])) def test_remote_master_non_empty_pool(self): - """Ensure AggregateError is raised if removing the master.""" + # Ensure AggregateError is raised if removing the master. aggregate = self._aggregate_setup(hosts=['host', 'host2'], metadata=self.fake_metadata) @@ -2415,7 +2415,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): aggregate, 'fake_host') def test_remove_host_from_aggregate_error(self): - """Ensure we can remove a host from an aggregate even if in error.""" + # Ensure we can remove a host from an aggregate even if in error. values = _create_service_entries(self.context) fake_zone = values.keys()[0] aggr = self.api.create_aggregate(self.context, @@ -2453,7 +2453,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): aggregate, 'fake_host') def test_add_aggregate_host_raise_err(self): - """Ensure the undo operation works correctly on add.""" + # Ensure the undo operation works correctly on add. def fake_driver_add_to_aggregate(context, aggregate, host, **_ignore): raise exception.AggregateError( aggregate_id='', action='', reason='') @@ -2492,7 +2492,7 @@ class MockComputeAPI(object): class StubDependencies(object): - """Stub dependencies for ResourcePool""" + """Stub dependencies for ResourcePool.""" def __init__(self): self.compute_rpcapi = MockComputeAPI() @@ -2511,7 +2511,7 @@ class StubDependencies(object): class ResourcePoolWithStubs(StubDependencies, pool.ResourcePool): - """A ResourcePool, use stub dependencies """ + """A ResourcePool, use stub dependencies.""" class HypervisorPoolTestCase(test.TestCase): diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index a44f3e9fd..85c85b5e2 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Stubouts, mocks and fixtures for the test suite""" +"""Stubouts, mocks and fixtures for the test suite.""" import pickle import random @@ -54,7 +54,7 @@ def stubout_instance_snapshot(stubs): def stubout_session(stubs, cls, product_version=(5, 6, 2), product_brand='XenServer', **opt_args): - """Stubs out methods from XenAPISession""" + """Stubs out methods from XenAPISession.""" stubs.Set(xenapi_conn.XenAPISession, '_create_session', lambda s, url: cls(url, **opt_args)) stubs.Set(xenapi_conn.XenAPISession, '_get_product_version_and_brand', @@ -90,7 +90,7 @@ def stubout_is_vdi_pv(stubs): def stubout_determine_is_pv_objectstore(stubs): - """Assumes VMs stu have PV kernels""" + """Assumes VMs stu have PV kernels.""" def f(*args): return False @@ -158,7 +158,7 @@ def _make_fake_vdi(): class FakeSessionForVMTests(fake.SessionBase): - """Stubs out a XenAPISession for VM tests """ + """Stubs out a XenAPISession for VM tests.""" _fake_iptables_save_output = ("# Generated by iptables-save v1.4.10 on " "Sun Nov 6 22:49:02 2011\n" @@ -204,7 +204,7 @@ class FakeSessionForVMTests(fake.SessionBase): class FakeSessionForFirewallTests(FakeSessionForVMTests): - """Stubs out a XenApi Session for doing IPTable Firewall tests """ + """Stubs out a XenApi Session for doing IPTable Firewall tests.""" def __init__(self, uri, test_case=None): super(FakeSessionForFirewallTests, self).__init__(uri) @@ -270,7 +270,7 @@ def stub_out_vm_methods(stubs): class FakeSessionForVolumeTests(fake.SessionBase): - """Stubs out a XenAPISession for Volume tests """ + """Stubs out a XenAPISession for Volume tests.""" def VDI_introduce(self, _1, uuid, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11): valid_vdi = False @@ -284,7 +284,7 @@ class FakeSessionForVolumeTests(fake.SessionBase): class FakeSessionForVolumeFailedTests(FakeSessionForVolumeTests): - """Stubs out a XenAPISession for Volume tests: it injects failures """ + """Stubs out a XenAPISession for Volume tests: it injects failures.""" def VDI_introduce(self, _1, uuid, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11): # This is for testing failure