Created
October 19, 2016 00:25
-
-
Save ahsan518/9e34867ef8fed9c77f280ccaabce0022 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
331 def net_interfaces_update(context, interface_id, values): | |
332 """Update an existing network interface.""" | |
~ 333 return IMPL.net_interfaces_update(context, interface_id, values) | |
334 |
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
826 def net_interfaces_update(context, interface_id, values): | |
827 """Update an existing network interface.""" | |
828 session = get_session() | |
829 with session.begin(): | |
830 ┆ query = model_query(context, models.NetInterface, | |
831 ┆ ┆ ┆ ┆ ┆ ┆ project_only=True) | |
832 ┆ query = query.filter_by(id=interface_id) | |
833 ┆ net_interface_ref = query.with_for_update().one() | |
834 net_interface_ref.update(values) | |
835 ┆ net_interface_ref.save(session) | |
836 ┆ return net_interface_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
testtools.testresult.real._StringException: Traceback (most recent call last): | |
File "/home/ubuntu/craton/craton/tests/unit/db/test_networks.py", line 182, in test_interface_update | |
{'name': 'eth2'}) | |
File "/home/ubuntu/craton/craton/db/api.py", line 333, in net_interfaces_update | |
return IMPL.net_interfaces_update(context, interface_id, values) | |
File "/home/ubuntu/craton/craton/db/sqlalchemy/api.py", line 835, in net_interfaces_update | |
net_interface_ref.save(session) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/oslo_db/sqlalchemy/models.py", line 47, in save | |
session.add(self) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 1588, in add | |
self._save_or_update_state(state) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 1600, in _save_or_update_state | |
self._save_or_update_impl(state) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 1861, in _save_or_update_impl | |
self._update_impl(state) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 1849, in _update_impl | |
self._before_attach(state, check_identity_map=False) | |
File "/home/ubuntu/craton/.tox/py35/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 1948, in _before_attach | |
state.session_id, self.hash_key)) | |
sqlalchemy.exc.InvalidRequestError: Object '<NetInterface at 0x7f5fa5beb1d0>' is already attached to session '84' (this is '83') | |
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
+ 174 def test_interface_update(self): | |
+ 175 ┆ interface = dbapi.net_interfaces_create(self.context, net_interface1) | |
+ 176 ┆ res = dbapi.net_interfaces_get_by_id(self.context, interface.id) | |
+ 177 # pdb.set_trace() | |
+ 178 # print (res) | |
+ 179 ┆ self.assertEqual(res.name, 'eth1') | |
+ 180 ┆ new_name = 'eth2' | |
+ 181 ┆ res = dbapi.net_interfaces_update(self.context, interface.id, | |
+ 182 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ {'name': 'eth2'}) | |
+ 183 ┆ self.assertEqual(res[0]['name'], new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment