From 1c6bb73b3df355b0100212e8732c8be16ee63624 Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Wed, 2 Jan 2013 08:43:39 -0500 Subject: Add unit test to update server metadata Fixes bug: 1088878 Partially implements blueprint nova-v2-api-audit The bug description points to 4 situations to be tested, although those situations are already tested on create metadata tests which use the same method as update_all to operate over metadata (_update_instance_metadata) so no more tests are needed. Change-Id: Ifae3c69c0e00c361ae36f5a8dede835c96568d11 --- nova/tests/api/openstack/compute/test_server_metadata.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'nova') diff --git a/nova/tests/api/openstack/compute/test_server_metadata.py b/nova/tests/api/openstack/compute/test_server_metadata.py index 78e3f866b..ade9e8ad1 100644 --- a/nova/tests/api/openstack/compute/test_server_metadata.py +++ b/nova/tests/api/openstack/compute/test_server_metadata.py @@ -253,6 +253,22 @@ class ServerMetaDataTest(test.TestCase): self.assertRaises(webob.exc.HTTPNotFound, self.controller.create, req, self.uuid, body) + def test_update_metadata(self): + self.stubs.Set(nova.db, 'instance_metadata_update', + return_create_instance_metadata) + req = fakes.HTTPRequest.blank(self.url) + req.method = 'POST' + req.content_type = 'application/json' + expected = { + 'metadata': { + 'key1': 'updatedvalue', + 'key29': 'newkey', + } + } + req.body = jsonutils.dumps(expected) + response = self.controller.update_all(req, self.uuid, expected) + self.assertEqual(expected, response) + def test_update_all(self): self.stubs.Set(nova.db, 'instance_metadata_update', return_create_instance_metadata) -- cgit