]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix incorrect number of args to string format
authorAngus Lees <gus@inodes.org>
Wed, 13 Aug 2014 05:39:36 +0000 (15:39 +1000)
committerAngus Lees <gus@inodes.org>
Wed, 27 Aug 2014 01:36:19 +0000 (11:36 +1000)
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
neutron/tests/unit/mlnx/test_mlnx_db.py

index 4b1bc94dcaf97ca8efd2c557f7ee31c3ff86c881..bdbce26cbe112af7ba128dcc09cbb9b62d0e3ea6 100644 (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)
index 6ece2044dc27dd1328a6e48f98cb7ccf9627cf3d..e0f7202a7a7efca17fe2c0b38e03d2067b21bb4a 100644 (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))