diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py index 65cdd5fc..b22d8b7b 100644 --- a/nova/tests/test_vmwareapi.py +++ b/nova/tests/test_vmwareapi.py @@ -16,8 +16,9 @@ # under the License. """ -Test suite for VMWareAPI +Test suite for VMWareAPI. """ + import stubout from nova import context @@ -38,9 +39,7 @@ FLAGS = flags.FLAGS class VMWareAPIVMTestCase(test.TestCase): - """ - Unit tests for Vmware API connection calls - """ + """Unit tests for Vmware API connection calls.""" def setUp(self): super(VMWareAPIVMTestCase, self).setUp() @@ -61,7 +60,7 @@ class VMWareAPIVMTestCase(test.TestCase): self.conn = vmwareapi_conn.get_connection(False) def _create_vm(self): - """ Create and spawn the VM """ + """Create and spawn the VM.""" values = {'name': 1, 'id': 1, 'project_id': self.project.id, @@ -78,15 +77,17 @@ class VMWareAPIVMTestCase(test.TestCase): self._check_vm_record() def _check_vm_record(self): - """ Check if the spawned VM's properties corresponds to the instance in - the db """ + """ + Check if the spawned VM's properties correspond to the instance in + the db. + """ instances = self.conn.list_instances() self.assertEquals(len(instances), 1) # Get Nova record for VM vm_info = self.conn.get_info(1) - # Get record for VMs + # Get record for VM vms = vmwareapi_fake._get_objects("VirtualMachine") vm = vms[0] @@ -106,8 +107,10 @@ class VMWareAPIVMTestCase(test.TestCase): self.assertEquals(vm.get("runtime.powerState"), 'poweredOn') def _check_vm_info(self, info, pwr_state=power_state.RUNNING): - """ Check if the get_info returned values correspond to the instance - object in the db """ + """ + Check if the get_info returned values correspond to the instance + object in the db. + """ mem_kib = long(self.type_data['memory_mb']) << 10 self.assertEquals(info["state"], pwr_state) self.assertEquals(info["max_mem"], mem_kib) @@ -194,8 +197,9 @@ class VMWareAPIVMTestCase(test.TestCase): pass def dummy_callback_handler(self, ret): - """ Dummy callback function to be passed to suspend, resume, etc. - calls """ + """ + Dummy callback function to be passed to suspend, resume, etc., calls. + """ pass def tearDown(self): diff --git a/nova/tests/vmwareapi/__init__.py b/nova/tests/vmwareapi/__init__.py index f346c053..478ee742 100644 --- a/nova/tests/vmwareapi/__init__.py +++ b/nova/tests/vmwareapi/__init__.py @@ -14,3 +14,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + +""" +:mod:`vmwareapi` -- Stubs for VMware API +======================================= +""" diff --git a/nova/tests/vmwareapi/db_fakes.py b/nova/tests/vmwareapi/db_fakes.py index 026a2038..0addd557 100644 --- a/nova/tests/vmwareapi/db_fakes.py +++ b/nova/tests/vmwareapi/db_fakes.py @@ -26,7 +26,7 @@ from nova import utils def stub_out_db_instance_api(stubs): - """ Stubs out the db API for creating Instances """ + """Stubs out the db API for creating Instances.""" INSTANCE_TYPES = { 'm1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1), @@ -38,7 +38,7 @@ def stub_out_db_instance_api(stubs): dict(memory_mb=16384, vcpus=8, local_gb=160, flavorid=5)} class FakeModel(object): - """ Stubs out for model """ + """Stubs out for model.""" def __init__(self, values): self.values = values @@ -53,7 +53,7 @@ def stub_out_db_instance_api(stubs): raise NotImplementedError() def fake_instance_create(values): - """ Stubs out the db.instance_create method """ + """Stubs out the db.instance_create method.""" type_data = INSTANCE_TYPES[values['instance_type']] @@ -77,7 +77,7 @@ def stub_out_db_instance_api(stubs): return FakeModel(base_options) def fake_network_get_by_instance(context, instance_id): - """ Stubs out the db.network_get_by_instance method """ + """Stubs out the db.network_get_by_instance method.""" fields = { 'bridge': 'vmnet0', @@ -87,11 +87,11 @@ def stub_out_db_instance_api(stubs): return FakeModel(fields) def fake_instance_action_create(context, action): - """ Stubs out the db.instance_action_create method """ + """Stubs out the db.instance_action_create method.""" pass def fake_instance_get_fixed_address(context, instance_id): - """ Stubs out the db.instance_get_fixed_address method """ + """Stubs out the db.instance_get_fixed_address method.""" return '10.10.10.10' def fake_instance_type_get_all(context, inactive=0): diff --git a/nova/tests/vmwareapi/stubs.py b/nova/tests/vmwareapi/stubs.py index da2d43c2..a648efb1 100644 --- a/nova/tests/vmwareapi/stubs.py +++ b/nova/tests/vmwareapi/stubs.py @@ -25,17 +25,17 @@ from nova.virt.vmwareapi import vmware_images def fake_get_vim_object(arg): - """ Stubs out the VMWareAPISession's get_vim_object method """ + """Stubs out the VMWareAPISession's get_vim_object method.""" return fake.FakeVim() def fake_is_vim_object(arg, module): - """ Stubs out the VMWareAPISession's is_vim_object method """ + """Stubs out the VMWareAPISession's is_vim_object method.""" return isinstance(module, fake.FakeVim) def set_stubs(stubs): - """ Set the stubs """ + """Set the stubs.""" stubs.Set(vmware_images, 'fetch_image', fake.fake_fetch_image) stubs.Set(vmware_images, 'get_vmdk_size_and_properties', fake.fake_get_vmdk_size_and_properties)