diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-02-06 01:00:30 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-02-06 01:00:30 +0000 |
| commit | bfd295daed4b22cd0716973bee33cffdaaeae931 (patch) | |
| tree | 31689400c872f4f26f7441b3d6e0fa84af215006 /nova/tests | |
| parent | af235b22eccb81d815c79fd1f531734a140cfafb (diff) | |
| parent | 5d8868a4d58122dce6fdc81fa0ed17ae7fc55672 (diff) | |
Merge "Refactor server password metadata to avoid direct db usage"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_server_password.py | 5 | ||||
| -rw-r--r-- | nova/tests/test_metadata.py | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_server_password.py b/nova/tests/api/openstack/compute/contrib/test_server_password.py index 600c4eda4..87da90efe 100644 --- a/nova/tests/api/openstack/compute/contrib/test_server_password.py +++ b/nova/tests/api/openstack/compute/contrib/test_server_password.py @@ -40,11 +40,12 @@ class ServerPasswordTest(test.TestCase): def fake_extract_password(instance): return self.password - def fake_set_password(context, instance_uuid, password): + def fake_convert_password(context, password): self.password = password + return {} self.stubs.Set(password, 'extract_password', fake_extract_password) - self.stubs.Set(password, 'set_password', fake_set_password) + self.stubs.Set(password, 'convert_password', fake_convert_password) self.flags( osapi_compute_extension=[ 'nova.api.openstack.compute.contrib.select_extensions'], diff --git a/nova/tests/test_metadata.py b/nova/tests/test_metadata.py index f610cd6fc..827bfb398 100644 --- a/nova/tests/test_metadata.py +++ b/nova/tests/test_metadata.py @@ -549,6 +549,7 @@ class MetadataPasswordTestCase(test.TestCase): self.instance = copy.copy(INSTANCES[0]) self.mdinst = fake_InstanceMetadata(self.stubs, self.instance, address=None, sgroups=None) + self.flags(use_local=True, group='conductor') def test_get_password(self): request = webob.Request.blank('') @@ -566,8 +567,16 @@ class MetadataPasswordTestCase(test.TestCase): request = webob.Request.blank('') request.method = 'POST' request.body = val - self.stubs.Set(db, 'instance_system_metadata_update', - lambda *a, **kw: None) + self.stubs.Set(db, 'instance_get_by_uuid', + lambda *a, **kw: {'system_metadata': []}) + + def fake_instance_update(context, uuid, updates): + self.assertIn('system_metadata', updates) + self.assertIn('password_0', updates['system_metadata']) + return self.instance, self.instance + + self.stubs.Set(db, 'instance_update_and_get_original', + fake_instance_update) password.handle_password(request, self.mdinst) def test_set_password(self): |
