Fix incorrect number of args to string format

Since there wasn't already one, also add a unittest for
PortProfileBinding and repr() functions.

Change-Id: Ibd8c5a21a7743af4c1c302495a65eeb5e45f6315
This commit is contained in:
Angus Lees 2014-08-13 15:39:36 +10:00
parent 921969d374
commit dca18ad307
2 changed files with 28 additions and 2 deletions

View File

@ -82,5 +82,5 @@ class PortProfileBinding(model_base.BASEV2):
self.vnic_type = vnic_type
def __repr__(self):
return "<PortProfileBinding(%s,%s,%s,%d)>" % (self.port_id,
self.vnic_type)
return "<PortProfileBinding(%s,%s)>" % (self.port_id,
self.vnic_type)

View File

@ -176,3 +176,29 @@ class NetworkBindingsTest(test_plugin.NeutronDbPluginV2TestCase):
self.assertEqual(binding.network_type, NET_TYPE)
self.assertEqual(binding.physical_network, PHYS_NET)
self.assertEqual(binding.segmentation_id, 1234)
self.assertTrue(repr(binding))
class PortProfileBindingTest(test_plugin.NeutronDbPluginV2TestCase):
def setUp(self):
super(PortProfileBindingTest, self).setUp()
self.session = db.get_session()
def test_add_port_profile_binding(self):
with self.port() as port:
TEST_PORT_ID = port['port']['id']
VNIC_TYPE = 'normal'
self.assertIsNone(mlnx_db.get_port_profile_binding(self.session,
TEST_PORT_ID))
mlnx_db.add_port_profile_binding(self.session,
TEST_PORT_ID,
VNIC_TYPE)
binding = mlnx_db.get_port_profile_binding(self.session,
TEST_PORT_ID)
self.assertIsNotNone(binding)
self.assertEqual(binding.port_id, TEST_PORT_ID)
self.assertEqual(binding.vnic_type, VNIC_TYPE)
self.assertTrue(repr(binding))