From 968f0e17cbb9dfe881bcb2fa0c96b6aea4f566fa Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 27 Jul 2011 20:48:26 -0400 Subject: remove unused assignment which causes undeclared name error --- nova/tests/scheduler/test_scheduler.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index daea826fd..18fbef5ca 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -485,11 +485,6 @@ class SimpleDriverTestCase(test.TestCase): self.assertEqual(host, 'host2') volume1.delete_volume(self.context, volume_id1) db.volume_destroy(self.context, volume_id2) - dic = {'service_id': s_ref['id'], - 'vcpus': 16, 'memory_mb': 32, 'local_gb': 100, - 'vcpus_used': 16, 'memory_mb_used': 12, 'local_gb_used': 10, - 'hypervisor_type': 'qemu', 'hypervisor_version': 12003, - 'cpu_info': ''} def test_doesnt_report_disabled_hosts_as_up(self): """Ensures driver doesn't find hosts before they are enabled""" -- cgit From 0e3f66bac655b49329b5e90f23599ba45333543b Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 28 Jul 2011 15:09:02 -0400 Subject: Some tests for resolved pylint errors. --- nova/tests/scheduler/test_zone_aware_scheduler.py | 20 ++++++++++++++++++++ nova/tests/test_xenapi.py | 15 +++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index d74b71fb6..14f8191f2 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -16,6 +16,9 @@ Tests For Zone Aware Scheduler. """ +import json +import mox + import nova.db from nova import exception @@ -327,3 +330,20 @@ class ZoneAwareSchedulerTestCase(test.TestCase): sched._provision_resource_from_blob(None, request_spec, 1, request_spec, {}) self.assertTrue(was_called) + + def test_decrypt_blob(self): + """Test that the decrypt method works.""" + + fixture = FakeZoneAwareScheduler() + test_data = {"foo": "bar"} + + crypto = self.mox.CreateMockAnything() + crypto.decryptor(mox.IgnoreArg()).AndReturn(lambda blob: blob) + """ + def _decryptor(i): + return lambda blob: blob + """ + self.stubs.Set(zone_aware_scheduler, 'crypto', + crypto) + + self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 8b3b5fa28..781a218b6 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -807,6 +807,21 @@ class XenAPIMigrateInstance(test.TestCase): conn.finish_resize(instance, dict(base_copy='hurr', cow='durr'), network_info) +class XenAPIImageTypeTestCase(test.TestCase): + """Test ImageType class.""" + + def test_to_string(self): + """Can convert from type id to type string.""" + self.assertEquals( + vm_utils.ImageType.to_string(vm_utils.ImageType.KERNEL), + vm_utils.ImageType.KERNEL_STR) + + def test_from_string(self): + """Can convert from string to type id.""" + self.assertEquals( + vm_utils.ImageType.to_string(vm_utils.ImageType.KERNEL_STR), + vm_utils.ImageType.KERNEL) + class XenAPIDetermineDiskImageTestCase(test.TestCase): """Unit tests for code that detects the ImageType.""" -- cgit From 782f86b931156bd81c05acabe200e123f6227ae4 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 28 Jul 2011 15:46:20 -0400 Subject: Fix tests for checking pylint errors. --- nova/tests/scheduler/test_zone_aware_scheduler.py | 12 +++++------- nova/tests/test_xenapi.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 14f8191f2..3781c567e 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -337,13 +337,11 @@ class ZoneAwareSchedulerTestCase(test.TestCase): fixture = FakeZoneAwareScheduler() test_data = {"foo": "bar"} - crypto = self.mox.CreateMockAnything() - crypto.decryptor(mox.IgnoreArg()).AndReturn(lambda blob: blob) - """ - def _decryptor(i): - return lambda blob: blob - """ + class StubDecryptor(object): + def decryptor(self, key): + return lambda blob: blob + self.stubs.Set(zone_aware_scheduler, 'crypto', - crypto) + StubDecryptor()) self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 781a218b6..e87622451 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -819,7 +819,7 @@ class XenAPIImageTypeTestCase(test.TestCase): def test_from_string(self): """Can convert from string to type id.""" self.assertEquals( - vm_utils.ImageType.to_string(vm_utils.ImageType.KERNEL_STR), + vm_utils.ImageType.from_string(vm_utils.ImageType.KERNEL_STR), vm_utils.ImageType.KERNEL) -- cgit From 7834ab495fa657105a41dc590628981b5d44d8b9 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 28 Jul 2011 17:41:13 -0400 Subject: fix pep8 errors --- nova/tests/scheduler/test_zone_aware_scheduler.py | 5 +++-- nova/tests/test_xenapi.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 3781c567e..043d0d5c8 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -343,5 +343,6 @@ class ZoneAwareSchedulerTestCase(test.TestCase): self.stubs.Set(zone_aware_scheduler, 'crypto', StubDecryptor()) - - self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) + + self.assertEqual(fixture._decrypt_blob(test_data), + json.dumps(test_data)) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index e87622451..df95f2c60 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -807,6 +807,7 @@ class XenAPIMigrateInstance(test.TestCase): conn.finish_resize(instance, dict(base_copy='hurr', cow='durr'), network_info) + class XenAPIImageTypeTestCase(test.TestCase): """Test ImageType class.""" -- cgit From 798dbb567be3e36eb2d6f0fbe27aa2eced0345d4 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Fri, 29 Jul 2011 14:58:49 -0400 Subject: remove unused import --- nova/tests/scheduler/test_zone_aware_scheduler.py | 1 - 1 file changed, 1 deletion(-) (limited to 'nova/tests') diff --git a/nova/tests/scheduler/test_zone_aware_scheduler.py b/nova/tests/scheduler/test_zone_aware_scheduler.py index 043d0d5c8..7833028c3 100644 --- a/nova/tests/scheduler/test_zone_aware_scheduler.py +++ b/nova/tests/scheduler/test_zone_aware_scheduler.py @@ -17,7 +17,6 @@ Tests For Zone Aware Scheduler. """ import json -import mox import nova.db -- cgit