From 1bf87dda57b076e042301eeafa966283265d08cf Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sat, 8 Jun 2013 13:18:51 +0200 Subject: Fix and enable H403 tests Multi-line doc-strings should end on a new, separate line. Change-Id: I4cf0cfe92b634ef77971863a4df41ef43531bc20 --- nova/tests/api/ec2/test_api.py | 18 ++++++++++++------ nova/tests/api/ec2/test_cloud.py | 3 ++- nova/tests/api/openstack/compute/test_limits.py | 3 ++- nova/tests/api/openstack/compute/test_servers.py | 3 ++- nova/tests/compute/test_compute.py | 20 +++++++++++++------- nova/tests/db/test_migrations.py | 7 +++++-- nova/tests/fake_ldap.py | 6 ++++-- nova/tests/integrated/test_api_samples.py | 4 +++- nova/tests/network/test_linux_net.py | 9 ++++++--- nova/tests/network/test_manager.py | 12 ++++++++---- nova/tests/scheduler/fakes.py | 3 ++- nova/tests/scheduler/test_chance_scheduler.py | 6 ++++-- nova/tests/scheduler/test_filter_scheduler.py | 13 +++++++++---- nova/tests/scheduler/test_scheduler.py | 3 ++- nova/tests/virt/libvirt/fakelibvirt.py | 1 + nova/tests/virt/libvirt/test_libvirt.py | 16 ++++++++++------ nova/tests/virt/test_virt_drivers.py | 6 ++++-- nova/tests/virt/xenapi/stubs.py | 4 +++- nova/tests/virt/xenapi/test_xenapi.py | 18 ++++++++++++------ 19 files changed, 104 insertions(+), 51 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/ec2/test_api.py b/nova/tests/api/ec2/test_api.py index 3c3ac6c6c..97d9a9279 100644 --- a/nova/tests/api/ec2/test_api.py +++ b/nova/tests/api/ec2/test_api.py @@ -276,7 +276,8 @@ class ApiEc2TestCase(test.TestCase): def test_describe_instances(self): """Test that, after creating a user and a project, the describe - instances call to the API works properly""" + instances call to the API works properly. + """ self.expect_http() self.mox.ReplayAll() self.assertEqual(self.ec2.get_all_instances(), []) @@ -290,7 +291,8 @@ class ApiEc2TestCase(test.TestCase): def test_get_all_key_pairs(self): """Test that, after creating a user and project and generating - a key pair, that the API call to list key pairs works properly""" + a key pair, that the API call to list key pairs works properly. + """ keyname = "".join(random.choice("sdiuisudfsdcnpaqwertasd") for x in range(random.randint(4, 8))) self.expect_http() @@ -302,7 +304,8 @@ class ApiEc2TestCase(test.TestCase): def test_create_duplicate_key_pair(self): """Test that, after successfully generating a keypair, - requesting a second keypair with the same name fails sanely""" + requesting a second keypair with the same name fails sanely. + """ self.expect_http() self.mox.ReplayAll() self.ec2.create_key_pair('test') @@ -351,10 +354,11 @@ class ApiEc2TestCase(test.TestCase): def test_group_name_valid_chars_security_group(self): """Test that we sanely handle invalid security group names. + EC2 API Spec states we should only accept alphanumeric characters, spaces, dashes, and underscores. Amazon implementation - accepts more characters - so, [:print:] is ok. """ - + accepts more characters - so, [:print:] is ok. + """ bad_strict_ec2 = "aa \t\x01\x02\x7f" bad_amazon_ec2 = "aa #^% -=99" test_raise = [ @@ -385,7 +389,9 @@ class ApiEc2TestCase(test.TestCase): def test_group_name_valid_length_security_group(self): """Test that we sanely handle invalid security group names. - API Spec states that the length should not exceed 255 chars """ + + API Spec states that the length should not exceed 255 char. + """ self.expect_http() self.mox.ReplayAll() diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index b4cb24404..543bf4a62 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -2346,7 +2346,8 @@ class CloudTestCase(test.TestCase): def test_instance_initiated_shutdown_behavior(self): def test_dia_iisb(expected_result, **kwargs): """test describe_instance_attribute - attribute instance_initiated_shutdown_behavior""" + attribute instance_initiated_shutdown_behavior + """ kwargs.update({'instance_type': CONF.default_flavor, 'max_count': 1}) instance_id = self._run_instance(**kwargs) diff --git a/nova/tests/api/openstack/compute/test_limits.py b/nova/tests/api/openstack/compute/test_limits.py index 79bb97d2a..b9dc72b1f 100644 --- a/nova/tests/api/openstack/compute/test_limits.py +++ b/nova/tests/api/openstack/compute/test_limits.py @@ -778,7 +778,8 @@ def wire_HTTPConnection_to_WSGI(host, app): """ class HTTPConnectionDecorator(object): """Wraps the real HTTPConnection class so that when you instantiate - the class you might instead get a fake instance.""" + the class you might instead get a fake instance. + """ def __init__(self, wrapped): self.wrapped = wrapped diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index 6a8c3702f..88e70efec 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -237,7 +237,8 @@ class ServersControllerTest(test.TestCase): def test_unique_host_id(self): """Create two servers with the same host and different - project_ids and check that the hostId's are unique""" + project_ids and check that the hostId's are unique. + """ def return_instance_with_host(self, *args): project_id = str(uuid.uuid4()) return fakes.stub_instance(id=1, uuid=FAKE_UUID, diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index cb658d55f..9787984bf 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1062,7 +1062,8 @@ class ComputeTestCase(BaseTestCase): """spawn failure test. Make sure that when there is a spawning problem, - the instance goes to ERROR state, keeping the task state""" + the instance goes to ERROR state, keeping the task state. + """ def fake(*args, **kwargs): raise test.TestingException() self.stubs.Set(self.compute.driver, 'spawn', fake) @@ -1080,7 +1081,8 @@ class ComputeTestCase(BaseTestCase): """spawn network deallocate test. Make sure that when an instance is not found during spawn - that the network is deallocated""" + that the network is deallocated + """ instance = self._create_instance() def fake(*args, **kwargs): @@ -3575,7 +3577,8 @@ class ComputeTestCase(BaseTestCase): def test_resize_same_source_fails(self): """Ensure instance fails to migrate when source and destination are - the same host""" + the same host. + """ reservations = self._ensure_quota_reservations_rolledback() instance = jsonutils.to_primitive(self._create_fake_instance()) self.compute.run_instance(self.context, instance=instance) @@ -7388,7 +7391,8 @@ class ComputeAPITestCase(BaseTestCase): def test_reservation_id_one_instance(self): """Verify building an instance has a reservation_id that - matches return value from create""" + matches return value from create. + """ (refs, resv_id) = self.compute_api.create(self.context, flavors.get_default_flavor(), None) try: @@ -7400,7 +7404,7 @@ class ComputeAPITestCase(BaseTestCase): def test_reservation_ids_two_instances(self): """Verify building 2 instances at once results in a reservation_id being returned equal to reservation id set - in both instances + in both instances. """ (refs, resv_id) = self.compute_api.create(self.context, flavors.get_default_flavor(), None, @@ -8222,7 +8226,8 @@ def _create_service_entries(context, values={'avail_zone1': ['fake_host1', class ComputeAPIAggrTestCase(BaseTestCase): """This is for unit coverage of aggregate-related methods - defined in nova.compute.api.""" + defined in nova.compute.api. + """ def setUp(self): super(ComputeAPIAggrTestCase, self).setUp() @@ -8332,7 +8337,8 @@ class ComputeAPIAggrTestCase(BaseTestCase): class ComputeAggrTestCase(BaseTestCase): """This is for unit coverage of aggregate-related methods - defined in nova.compute.manager.""" + defined in nova.compute.manager. + """ def setUp(self): super(ComputeAggrTestCase, self).setUp() diff --git a/nova/tests/db/test_migrations.py b/nova/tests/db/test_migrations.py index 3efa8c6bc..a1d2f402e 100644 --- a/nova/tests/db/test_migrations.py +++ b/nova/tests/db/test_migrations.py @@ -1418,8 +1418,11 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn): self.assertTrue(db_utils.check_shadow_table(engine, 'console_pools')) def _unique_constraint_check_migrate_185(self, engine, check=True): - """Test check unique constraint behavior. It should be the same before - and after migration because we changed their names only.""" + """Test check unique constraint behavior. + + It should be the same before and after migration because we + changed their names only. + """ data_list = [ ("floating_ips", {'address': '10.12.14.16', 'deleted': 0}), diff --git a/nova/tests/fake_ldap.py b/nova/tests/fake_ldap.py index 7b587ffe2..d7d1df9c5 100644 --- a/nova/tests/fake_ldap.py +++ b/nova/tests/fake_ldap.py @@ -57,8 +57,10 @@ class _StorageDict(dict): self.clear() def hgetall(self, key): - """Returns the hash for the given key; creates - the hash if the key doesn't exist.""" + """Returns the hash for the given key + + Creates the hash if the key doesn't exist. + """ try: return self[key] except KeyError: diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index a7e66cefd..82df0736d 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -2132,7 +2132,9 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): def setUp(self): """setUp Method for AdminActions api samples extension - This method creates the server that will be used in each tests""" + + This method creates the server that will be used in each tests + """ super(AdminActionsSamplesJsonTest, self).setUp() self.uuid = self._post_server() diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py index 4829f2d93..b08d247ff 100644 --- a/nova/tests/network/test_linux_net.py +++ b/nova/tests/network/test_linux_net.py @@ -405,7 +405,8 @@ class LinuxNetworkTestCase(test.TestCase): def test_linux_bridge_driver_plug(self): """Makes sure plug doesn't drop FORWARD by default. - Ensures bug 890195 doesn't reappear.""" + Ensures bug 890195 doesn't reappear. + """ def fake_execute(*args, **kwargs): return "", "" @@ -423,7 +424,8 @@ class LinuxNetworkTestCase(test.TestCase): def test_vlan_override(self): """Makes sure vlan_interface flag overrides network bridge_interface. - Allows heterogeneous networks a la bug 833426""" + Allows heterogeneous networks a la bug 833426 + """ driver = linux_net.LinuxBridgeInterfaceDriver() @@ -452,7 +454,8 @@ class LinuxNetworkTestCase(test.TestCase): def test_flat_override(self): """Makes sure flat_interface flag overrides network bridge_interface. - Allows heterogeneous networks a la bug 833426""" + Allows heterogeneous networks a la bug 833426 + """ driver = linux_net.LinuxBridgeInterfaceDriver() diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index d534e7857..82b79794f 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -1069,7 +1069,8 @@ class VlanNetworkTestCase(test.TestCase): def test_ip_association_and_allocation_of_other_project(self): """Makes sure that we cannot deallocaate or disassociate - a public ip of other project""" + a public ip of other project. + """ def network_get(_context, network_id, project_only="allow_none"): return networks[network_id] @@ -1123,7 +1124,8 @@ class VlanNetworkTestCase(test.TestCase): def test_deallocate_fixed(self): """Verify that release is called properly. - Ensures https://bugs.launchpad.net/nova/+bug/973442 doesn't return""" + Ensures https://bugs.launchpad.net/nova/+bug/973442 doesn't return + """ def network_get(_context, network_id, project_only="allow_none"): return networks[network_id] @@ -1193,7 +1195,8 @@ class VlanNetworkTestCase(test.TestCase): def test_deallocate_fixed_no_vif(self): """Verify that deallocate doesn't raise when no vif is returned. - Ensures https://bugs.launchpad.net/nova/+bug/968457 doesn't return""" + Ensures https://bugs.launchpad.net/nova/+bug/968457 doesn't return + """ def network_get(_context, network_id, project_only="allow_none"): return networks[network_id] @@ -1905,7 +1908,8 @@ class RPCAllocateTestCase(test.TestCase): """Test to verify bug 855030 doesn't resurface. Mekes sure _rpc_allocate_fixed_ip returns a value so the call - returns properly and the greenpool completes.""" + returns properly and the greenpool completes. + """ address = '10.10.10.10' def fake_allocate(*args, **kwargs): diff --git a/nova/tests/scheduler/fakes.py b/nova/tests/scheduler/fakes.py index 3dfc7c452..0ceb45282 100644 --- a/nova/tests/scheduler/fakes.py +++ b/nova/tests/scheduler/fakes.py @@ -77,7 +77,8 @@ class FakeHostManager(host_manager.HostManager): """host1: free_ram_mb=1024-512-512=0, free_disk_gb=1024-512-512=0 host2: free_ram_mb=2048-512=1536 free_disk_gb=2048-512=1536 host3: free_ram_mb=4096-1024=3072 free_disk_gb=4096-1024=3072 - host4: free_ram_mb=8192 free_disk_gb=8192""" + host4: free_ram_mb=8192 free_disk_gb=8192 + """ def __init__(self): super(FakeHostManager, self).__init__() diff --git a/nova/tests/scheduler/test_chance_scheduler.py b/nova/tests/scheduler/test_chance_scheduler.py index 8a281073a..cfe7f5d63 100644 --- a/nova/tests/scheduler/test_chance_scheduler.py +++ b/nova/tests/scheduler/test_chance_scheduler.py @@ -41,7 +41,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_filter_hosts_avoid(self): """Test to make sure _filter_hosts() filters original hosts if - avoid_original_host is True.""" + avoid_original_host is True. + """ hosts = ['host1', 'host2', 'host3'] request_spec = dict(instance_properties=dict(host='host2')) @@ -53,7 +54,8 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_filter_hosts_no_avoid(self): """Test to make sure _filter_hosts() does not filter original - hosts if avoid_original_host is False.""" + hosts if avoid_original_host is False. + """ hosts = ['host1', 'host2', 'host3'] request_spec = dict(instance_properties=dict(host='host2')) diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index b82e079a4..d6cc7808e 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -160,7 +160,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_schedule_happy_day(self): """Make sure there's nothing glaringly wrong with _schedule() - by doing a happy day pass through.""" + by doing a happy day pass through. + """ self.next_weight = 1.0 @@ -625,7 +626,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_schedule_large_host_pool(self): """Hosts should still be chosen if pool size - is larger than number of filtered hosts""" + is larger than number of filtered hosts. + """ sched = fakes.FakeFilterScheduler() @@ -653,7 +655,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_schedule_chooses_best_host(self): """If scheduler_host_subset_size is 1, the largest host with greatest - weight should be returned""" + weight should be returned. + """ self.flags(scheduler_host_subset_size=1) @@ -697,8 +700,10 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): def test_select_hosts_happy_day(self): """select_hosts is basically a wrapper around the _select() method. + Similar to the _select tests, this just does a happy path test to - ensure there is nothing glaringly wrong.""" + ensure there is nothing glaringly wrong. + """ self.next_weight = 1.0 diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 5663f1378..687444dae 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -931,7 +931,8 @@ class SchedulerTestCase(test.NoDBTestCase): class SchedulerDriverBaseTestCase(SchedulerTestCase): """Test cases for base scheduler driver class methods - that can't will fail if the driver is changed""" + that can't will fail if the driver is changed. + """ def test_unimplemented_schedule_run_instance(self): fake_args = (1, 2, 3) diff --git a/nova/tests/virt/libvirt/fakelibvirt.py b/nova/tests/virt/libvirt/fakelibvirt.py index 9594757a8..5435ee13b 100644 --- a/nova/tests/virt/libvirt/fakelibvirt.py +++ b/nova/tests/virt/libvirt/fakelibvirt.py @@ -618,6 +618,7 @@ class Connection(object): self._event_callbacks[eventid] = [callback, opaque] def getCapabilities(self): + """Return spoofed capabilities.""" return ''' cef19ce0-0ca2-11df-855d-b19fbce37686 diff --git a/nova/tests/virt/libvirt/test_libvirt.py b/nova/tests/virt/libvirt/test_libvirt.py index d46b08946..3e0da41b2 100644 --- a/nova/tests/virt/libvirt/test_libvirt.py +++ b/nova/tests/virt/libvirt/test_libvirt.py @@ -309,6 +309,7 @@ class LibvirtConnTestCase(test.TestCase): class FakeConn(): def getCapabilities(self): + """Ensure standard capabilities being returned.""" return """ x86_64 """ @@ -4841,7 +4842,8 @@ class LibvirtDriverTestCase(test.TestCase): def test_migrate_disk_and_power_off_exception(self): """Test for nova.virt.libvirt.libvirt_driver.LivirtConnection - .migrate_disk_and_power_off. """ + .migrate_disk_and_power_off. + """ self.counter = 0 self.checked_shared_storage = False @@ -4885,7 +4887,8 @@ class LibvirtDriverTestCase(test.TestCase): def test_migrate_disk_and_power_off(self): """Test for nova.virt.libvirt.libvirt_driver.LivirtConnection - .migrate_disk_and_power_off. """ + .migrate_disk_and_power_off. + """ disk_info = [{'type': 'qcow2', 'path': '/test/disk', 'virt_disk_size': '10737418240', @@ -4957,7 +4960,8 @@ class LibvirtDriverTestCase(test.TestCase): def _test_finish_migration(self, power_on): """Test for nova.virt.libvirt.libvirt_driver.LivirtConnection - .finish_migration. """ + .finish_migration. + """ disk_info = [{'type': 'qcow2', 'path': '/test/disk', 'local_gb': 10, 'backing_file': '/base/disk'}, @@ -5037,7 +5041,8 @@ class LibvirtDriverTestCase(test.TestCase): def _test_finish_revert_migration(self, power_on): """Test for nova.virt.libvirt.libvirt_driver.LivirtConnection - .finish_revert_migration. """ + .finish_revert_migration. + """ powered_on = power_on self.fake_create_domain_called = False @@ -5324,8 +5329,7 @@ class LibvirtDriverTestCase(test.TestCase): class LibvirtVolumeUsageTestCase(test.TestCase): - """Test for nova.virt.libvirt.libvirt_driver.LibvirtDriver - .get_all_volume_usage""" + """Test for LibvirtDriver.get_all_volume_usage.""" def setUp(self): super(LibvirtVolumeUsageTestCase, self).setUp() diff --git a/nova/tests/virt/test_virt_drivers.py b/nova/tests/virt/test_virt_drivers.py index c054b9624..1888a6b4c 100644 --- a/nova/tests/virt/test_virt_drivers.py +++ b/nova/tests/virt/test_virt_drivers.py @@ -39,7 +39,8 @@ def catch_notimplementederror(f): If a particular call makes a driver raise NotImplementedError, we log it so that we can extract this information afterwards to - automatically generate a hypervisor/feature support matrix.""" + automatically generate a hypervisor/feature support matrix. + """ def wrapped_func(self, *args, **kwargs): try: return f(self, *args, **kwargs) @@ -147,7 +148,8 @@ class _FakeDriverBackendTestCase(object): class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase, test.TestCase): """Test that ComputeManager can successfully load both old style and new style drivers and end up with the correct - final class""" + final class. + """ # if your driver supports being tested in a fake way, it can go here # diff --git a/nova/tests/virt/xenapi/stubs.py b/nova/tests/virt/xenapi/stubs.py index fa214b23e..d83a45fe8 100644 --- a/nova/tests/virt/xenapi/stubs.py +++ b/nova/tests/virt/xenapi/stubs.py @@ -99,7 +99,9 @@ def stubout_determine_is_pv_objectstore(stubs): def stubout_is_snapshot(stubs): """Always returns true - xenapi fake driver does not create vmrefs for snapshots """ + + xenapi fake driver does not create vmrefs for snapshots. + """ def f(*args): return True diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py index d99fdcb8e..ad41345d8 100644 --- a/nova/tests/virt/xenapi/test_xenapi.py +++ b/nova/tests/virt/xenapi/test_xenapi.py @@ -1766,7 +1766,8 @@ class CompareVersionTestCase(test.TestCase): class XenAPIHostTestCase(stubs.XenAPITestBase): """Tests HostState, which holds metrics from XenServer that get - reported back to the Schedulers.""" + reported back to the Schedulers. + """ def setUp(self): super(XenAPIHostTestCase, self).setUp() @@ -2728,7 +2729,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): def test_add_host_to_aggregate_invalid_changing_status(self): """Ensure InvalidAggregateAction is raised when adding host while - aggregate is not ready.""" + aggregate is not ready. + """ aggregate = self._aggregate_setup(aggr_state=pool_states.CHANGING) self.assertRaises(exception.InvalidAggregateAction, self.conn.add_to_aggregate, self.context, @@ -2736,7 +2738,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): def test_add_host_to_aggregate_invalid_dismissed_status(self): """Ensure InvalidAggregateAction is raised when aggregate is - deleted.""" + deleted. + """ aggregate = self._aggregate_setup(aggr_state=pool_states.DISMISSED) self.assertRaises(exception.InvalidAggregateAction, self.conn.add_to_aggregate, self.context, @@ -2744,7 +2747,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): def test_add_host_to_aggregate_invalid_error_status(self): """Ensure InvalidAggregateAction is raised when aggregate is - in error.""" + in error. + """ aggregate = self._aggregate_setup(aggr_state=pool_states.ERROR) self.assertRaises(exception.InvalidAggregateAction, self.conn.add_to_aggregate, self.context, @@ -2774,7 +2778,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): def test_remove_host_from_aggregate_invalid_dismissed_status(self): """Ensure InvalidAggregateAction is raised when aggregate is - deleted.""" + deleted. + """ aggregate = self._aggregate_setup(aggr_state=pool_states.DISMISSED) self.assertRaises(exception.InvalidAggregateAction, self.conn.remove_from_aggregate, self.context, @@ -2782,7 +2787,8 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): def test_remove_host_from_aggregate_invalid_changing_status(self): """Ensure InvalidAggregateAction is raised when aggregate is - changing.""" + changing. + """ aggregate = self._aggregate_setup(aggr_state=pool_states.CHANGING) self.assertRaises(exception.InvalidAggregateAction, self.conn.remove_from_aggregate, self.context, -- cgit