From dca18ad307fdc9f33ab3421478c7fce373a1264d Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Wed, 13 Aug 2014 15:39:36 +1000 Subject: [PATCH] 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 --- neutron/plugins/mlnx/db/mlnx_models_v2.py | 4 ++-- neutron/tests/unit/mlnx/test_mlnx_db.py | 26 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/mlnx/db/mlnx_models_v2.py b/neutron/plugins/mlnx/db/mlnx_models_v2.py index 4b1bc94dc..bdbce26cb 100644 --- a/neutron/plugins/mlnx/db/mlnx_models_v2.py +++ b/neutron/plugins/mlnx/db/mlnx_models_v2.py @@ -82,5 +82,5 @@ class PortProfileBinding(model_base.BASEV2): self.vnic_type = vnic_type def __repr__(self): - return "" % (self.port_id, - self.vnic_type) + return "" % (self.port_id, + self.vnic_type) diff --git a/neutron/tests/unit/mlnx/test_mlnx_db.py b/neutron/tests/unit/mlnx/test_mlnx_db.py index 6ece2044d..e0f7202a7 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_db.py +++ b/neutron/tests/unit/mlnx/test_mlnx_db.py @@ -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))