]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Handle long integer conversion in NEC portinfo validation tests
authorMatt Riedemann <mriedem@us.ibm.com>
Fri, 20 Sep 2013 15:47:25 +0000 (08:47 -0700)
committerMatt Riedemann <mriedem@us.ibm.com>
Sat, 21 Sep 2013 18:55:54 +0000 (11:55 -0700)
There are a couple of tests for NEC portinfo validation that pass an id
which gets converted to a base-16 integer and then that gets converted
to a hex string. The problem is the integer conversion can make it a
long integer and then the hex built-in appends 'L' to the string, and
the tests do not account for that. This patch handles that case.

Closes-Bug: #1228212

Change-Id: Id3aed686329dae9cc4777213a4d2bcf406652e15

neutron/tests/unit/nec/test_portbindings.py

index 2c096af8fa07814ce1fb97e8ca2f282ec32b074c..e534e2a5fcfcd5be30e5568bcc63be2f7bd5f3ac 100644 (file)
@@ -265,14 +265,22 @@ class TestNecPortBindingValidatePortInfo(test_nec_plugin.NecPluginV2TestCase):
         profile = {'portinfo:datapath_id': '0x1234567890abcdef',
                    'portinfo:port_no': 123}
         portinfo = self.plugin._validate_portinfo(profile)
-        self.assertEqual(portinfo['datapath_id'], '0x1234567890abcdef')
+        # NOTE(mriedem): Handle long integer conversion universally.
+        self.assertEqual(
+            0x1234567890abcdef,
+            int(portinfo['datapath_id'].replace('L', ''), 16)
+        )
         self.assertEqual(portinfo['port_no'], 123)
 
     def test_validate_portinfo_ok_without_0x(self):
         profile = {'portinfo:datapath_id': '1234567890abcdef',
                    'portinfo:port_no': 123}
         portinfo = self.plugin._validate_portinfo(profile)
-        self.assertEqual(portinfo['datapath_id'], '0x1234567890abcdef')
+        # NOTE(mriedem): Handle long integer conversion universally.
+        self.assertEqual(
+            0x1234567890abcdef,
+            int(portinfo['datapath_id'].replace('L', ''), 16)
+        )
         self.assertEqual(portinfo['port_no'], 123)
 
     def _test_validate_exception(self, profile, expected_msg):