Merge "improve UT coverage for nicira_db operations"

This commit is contained in:
Jenkins 2014-02-08 01:14:38 +00:00 committed by Gerrit Code Review
commit 7929b6e2b9
2 changed files with 13 additions and 0 deletions

View File

@ -67,6 +67,10 @@ def add_neutron_nsx_port_mapping(session, neutron_id,
LOG.debug(_("Port mapping for %s already available"), neutron_id)
else:
raise
except d_exc.DBError:
# rollback for any other db error
session.rollback()
raise
return mapping

View File

@ -77,3 +77,12 @@ class NiciraDBTestCase(base.BaseTestCase):
nicira_db.add_neutron_nsx_port_mapping,
self.ctx.session, neutron_port_id,
nsx_switch_id, nsx_port_id_2)
def test_add_neutron_nsx_port_mapping_raise_integrity_constraint(self):
neutron_port_id = 'foo_neutron_port_id'
nsx_port_id = 'foo_nsx_port_id'
nsx_switch_id = 'foo_nsx_switch_id'
self.assertRaises(d_exc.DBError,
nicira_db.add_neutron_nsx_port_mapping,
self.ctx.session, neutron_port_id,
nsx_switch_id, nsx_port_id)