def test_nexusportswitchbinding_get(self):
        """Tests get of port bindings based on port and switch."""
        npb11 = self._npb_test_obj(10, 100)
        npb21 = self._npb_test_obj(20, 100, switch='2.2.2.2')
        npb22 = self._npb_test_obj(20, 200, switch='2.2.2.2')
        self._add_bindings_to_db([npb11, npb21, npb22])

        npb = self._get_port_switch_bindings(npb11)
        self.assertEqual(len(npb), 1)
        self._assert_bindings_match(npb[0], npb11)
        npb_all_p20 = self._get_port_switch_bindings(npb21)
        self.assertEqual(len(npb_all_p20), 2)

        npb = nexus_db_v2.get_port_switch_bindings(npb21.port, "dummySwitch")
        self.assertIsNone(npb)
 def _get_port_switch_bindings(self, npb):
     """Get port bindings based on port and switch."""
     return nexus_db_v2.get_port_switch_bindings(npb.port, npb.switch)