'Test update of server flavor if server resize has not started.
Server resize is asynchronous operation in nova. So when heat is
requesting resize and polling the server then the server may still be
in ACTIVE state. So we need to wait some amount of time till the server
status becomes RESIZE.'

def test_server_update_flavor_resize_has_not_started(self):

    server = self.fc.servers.list()[1]
    server.id = '1234'
    server_resource = self._create_test_server(server, 'resize_server')
    update_props = self.server_props.copy()
    update_props['flavor'] = 'm1.small'
    update_template = server_resource.t.freeze(properties=update_props)
    def set_status(status):
        server.status = status
        return server
    self.patchobject(self.fc.servers, 'get', side_effect=[set_status('ACTIVE'), set_status('ACTIVE'), set_status('RESIZE'), set_status('VERIFY_RESIZE'), set_status('VERIFY_RESIZE'), set_status('ACTIVE')])
    mock_post = self.patchobject(self.fc.client, 'post_servers_1234_action', return_value=(202, None))
    scheduler.TaskRunner(server_resource.update, update_template)()
    self.assertEqual((server_resource.UPDATE, server_resource.COMPLETE), server_resource.state)
    mock_post.called_once_with(body={'resize': {'flavorRef': 2}})
    mock_post.called_once_with(body={'confirmResize': None})
