'Tests that if no networks are requested and no networks are
available, we fail with InterfaceAttachFailedNoNetwork.'

@mock.patch('nova.network.neutronv2.api._filter_hypervisor_macs')
@mock.patch('nova.network.neutronv2.api.API._validate_requested_port_ids')
@mock.patch('nova.network.neutronv2.api.API._has_port_binding_extension')
@mock.patch('nova.network.neutronv2.api.API._get_available_networks')
@mock.patch('nova.network.neutronv2.api.get_client')
def test_allocate_port_for_instance_no_networks(self, mock_getclient, mock_avail_nets, mock_has_pbe, mock_validate_port_ids, mock_filter_macs):

    instance = fake_instance.fake_instance_obj(self.context)
    mock_has_pbe.return_value = False
    mock_validate_port_ids.return_value = ({}, [])
    mock_filter_macs.return_value = None
    mock_avail_nets.return_value = []
    api = neutronapi.API()
    ex = self.assertRaises(exception.InterfaceAttachFailedNoNetwork, api.allocate_port_for_instance, self.context, instance, port_id=None)
    self.assertEqual("No    specific    network    was    requested    and    none    are    available    for    project    'fake-project'.", six.text_type(ex))
