def test_get_all_bnp_switch_port_maps(self):
     """Test get_all_bnp_switch_port_maps method."""
     sw_dict = self._get_bnp_phys_switch_dict()
     phy_switch = db.add_bnp_phys_switch(self.ctx, sw_dict)
     port_dict = self._get_bnp_neutron_port_dict()
     db.add_bnp_neutron_port(self.ctx, port_dict)
     port_map = self._get_bnp_switch_port_map_dict()
     port_map['switch_id'] = phy_switch['id']
     db.add_bnp_switch_port_map(self.ctx, port_map)
     ports = db.get_all_bnp_switch_port_maps(self.ctx)
     self.assertEqual(ports[0][0], port_map['neutron_port_id'])
 def index(self, request, **kwargs):
     context = request.context
     req_dict = dict(request.GET)
     filter_dict = self.get_filter_dict(**req_dict)
     port_maps = db.get_all_bnp_switch_port_maps(context, filter_dict)
     port_list = []
     for port_map in port_maps:
         if (port_map[5] == 0):
             bind_val = const.BIND_SUCCESS
         else:
             bind_val = const.BIND_FAILURE
         port_dict = {'neutron_port_id': port_map[0],
                      'switch_port_name': port_map[1],
                      'lag_id': port_map[2],
                      'segmentation_id': str(port_map[3]),
                      'access_type': port_map[4],
                      'bind_status': bind_val,
                      'switch_name': port_map[6]}
         port_list.append(port_dict)
     return {'bnp_switch_ports': port_list}