Last active
October 13, 2016 22:26
-
-
Save ahsan518/4b56e7b4dc1cfff5b41f393ab5856049 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 def cells_update(context, cell_id, values): | |
81 """Update an existing cell.""" | |
82 return IMPL.cells_update(context, cell_id, values) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 def cells_update(context, cell_id, values): | |
205 """Update an existing cell.""" | |
206 session = get_session() | |
207 with session.begin(): | |
208 ┆ query = model_query(context, models.Cell, session=session, | |
209 ┆ ┆ ┆ ┆ ┆ ┆ project_only=True) | |
210 ┆ query = query.filter_by(id=cell_id) | |
211 ┆ try: | |
212 ┆ ┆ cell_ref = query.with_lockmode('update').one() | |
213 ┆ except Exception: | |
214 ┆ ┆ raise | |
215 | |
216 cell_ref.update(values) | |
217 ┆ cell_ref.save(session) | |
218 return cell_ref |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR: craton.tests.unit.db.test_cells.CellsDBTestCase.test_cell_update | |
---------------------------------------------------------------------- | |
testtools.testresult.real._StringException: Traceback (most recent call last): | |
File "/home/ubuntu/craton/craton/tests/unit/db/test_cells.py", line 59, in test_cell_update | |
res = dbapi.cells_update(self.context, res.id, name) | |
File "/home/ubuntu/craton/craton/db/api.py", line 82, in cells_update | |
return IMPL.cells_update(context, cell_id, values) | |
File "/home/ubuntu/craton/craton/db/sqlalchemy/api.py", line 216, in cells_update | |
cell_ref.update(values) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/oslo_db/sqlalchemy/models.py", line 93, in update | |
for k, v in six.iteritems(values): | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/six.py", line 581, in iteritems | |
return iter(d.items(**kw)) | |
AttributeError: 'str' object has no attribute 'items' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 def test_cell_update(self): | |
54 ┆ dbapi.cells_create(self.context, cell1) | |
55 ┆ res = dbapi.cells_get_by_name(self.context, cell1['region_id'], | |
56 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ cell1['name']) | |
~ 57 ┆ self.assertEqual(res.name, 'cell1') | |
58 ┆ name = "cell1" | |
59 ┆ res = dbapi.cells_update(self.context, res.id, name) | |
60 ┆ self.assertEqual(res.name, name) | |
61 ┆ new_name = 'cell1_New' | |
62 res = dbapi.cells_update(self.context, res.id, new_name) | |
63 ┆ self.assertEqual(res.name, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment