'Test that complex metadata values are correctly serialized to JSON.
Test that complex metadata values are correctly serialized to JSON when
sent to Nova.'

def test_server_update_nova_metadata_complex(self):

    return_server = self.fc.servers.list()[1]
    server = self._create_test_server(return_server, 'md_update')
    self.patchobject(self.fc.servers, 'get', return_value=return_server)
    new_meta = {'test': {'testkey': 'testvalue'}}
    set_meta_mock = self.patchobject(self.fc.servers, 'set_meta')
    update_props = self.server_props.copy()
    update_props['metadata'] = new_meta
    update_template = server.t.freeze(properties=update_props)
    scheduler.TaskRunner(server.update, update_template)()
    self.assertEqual((server.UPDATE, server.COMPLETE), server.state)
    set_meta_mock.assert_called_with(return_server, server.client_plugin().meta_serialize(new_meta))
