Replace deprecated with_lockmode with with_for_update

The Query.with_lockmode() method is deprecated since version 0.9.0
and will be removed in a future release. [1]
This patch replaces it with Query.with_for_update().
The 'faultstring' was been modified to 'Exactly 5 or 6 columns has to be
specified for iterator expression', so adds one space between "iterator"
and "expression" for 'expected_error_msg'.

Also use upper-constraints in doc build to avoid issues in pdf build.

[1]
https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.orm.query.Query.with_lockmode

Closes-Bug: #1933226
Change-Id: I0ad514da647bb08790259fd27e56a41f6dbbbaa0
This commit is contained in:
ericxiett 2021-06-24 12:27:05 +00:00 committed by yatin
parent 863815153e
commit 9ca44fa3ab
3 changed files with 7 additions and 5 deletions

View File

@ -49,7 +49,9 @@ commands =
[testenv:docs]
setenv = PYTHONHASHSEED=0
deps = -r{toxinidir}/doc/requirements.txt
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
commands =
rm -fr doc/build doc/source/api/ .autogenerated
sphinx-build -W --keep-going -b html doc/source doc/build/html

View File

@ -278,7 +278,7 @@ class Connection(api.BaseConnection):
query = model_query(model, session=session)
query = add_identity_filter(query, id_)
try:
ref = query.with_lockmode('update').one()
ref = query.with_for_update().one()
except exc.NoResultFound:
raise exception.ResourceNotFound(name=model.__name__, id=id_)
@ -815,7 +815,7 @@ class Connection(api.BaseConnection):
query = model_query(models.Action, session=session)
query = add_identity_filter(query, action_id)
try:
ref = query.with_lockmode('update').one()
ref = query.with_for_update().one()
except exc.NoResultFound:
raise exception.ActionNotFound(action=action_id)
@ -900,7 +900,7 @@ class Connection(api.BaseConnection):
query = model_query(models.ActionPlan, session=session)
query = add_identity_filter(query, action_plan_id)
try:
ref = query.with_lockmode('update').one()
ref = query.with_for_update().one()
except exc.NoResultFound:
raise exception.ActionPlanNotFound(action_plan=action_plan_id)

View File

@ -700,7 +700,7 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(500, response.status_int)
expected_error_msg = ('Exactly 5 or 6 columns has to be '
'specified for iteratorexpression.')
'specified for iterator expression.')
self.assertTrue(response.json['error_message'])
self.assertIn(expected_error_msg, response.json['error_message'])