# Path: bgpvpn_dashboard/api/bgpvpn.py
# LOG = logging.getLogger(__name__)
# class Bgpvpn(neutron.NeutronAPIDictWrapper):
# class NetworkAssociation(neutron.NeutronAPIDictWrapper):
# class RouterAssociation(neutron.NeutronAPIDictWrapper):
# def bgpvpns_list(request, **kwargs):
# def bgpvpn_get(request, bgpvpn_id, **kwargs):
# def bgpvpn_create(request, **kwargs):
# def bgpvpn_update(request, bgpvpn_id, **kwargs):
# def bgpvpn_delete(request, bgpvpn_id):
# def network_association_get(request, bgpvpn_id, network_assoc_id, **kwargs):
# def network_association_list(request, bgpvpn_id, **kwargs):
# def network_association_create(request, bgpvpn_id, **kwargs):
# def network_association_delete(request, resource_id, bgpvpn_id):
# def router_association_get(request, bgpvpn_id, router_assoc_id, **kwargs):
# def router_association_list(request, bgpvpn_id, **kwargs):
# def router_association_create(request, bgpvpn_id, **kwargs):
# def router_association_update(request, bgpvpn_id, router_association_id,
#                               **kwargs):
# def router_association_delete(request, resource_id, bgpvpn_id):
# 
# Path: bgpvpn_dashboard/dashboards/admin/bgpvpn/tables.py
# LOG = logging.getLogger(__name__)
# class DeleteBgpvpn(policy.PolicyTargetMixin, tables.DeleteAction):
# class CreateBgpVpn(tables.LinkAction):
# class EditInfoBgpVpn(project_tables.EditInfoBgpVpn):
# class CreateNetworkAssociation(project_tables.CreateNetworkAssociation):
# class CreateRouterAssociation(project_tables.CreateRouterAssociation):
# class BgpvpnTable(project_tables.BgpvpnTable):
#     class Meta(object):
#     def action_present(count):
#     def action_past(count):
#     def delete(self, request, obj_id):
# def get_route_targets(bgpvpn):
# def get_import_targets(bgpvpn):
# def get_export_targets(bgpvpn):
# def get_network_url(network):
# def get_router_url(router):
# 
# Path: bgpvpn_dashboard/dashboards/admin/bgpvpn/views.py
# class IndexView(project_views.IndexView):
# class CreateView(forms.ModalFormView):
# class EditDataView(project_views.EditDataView):
# class CreateNetworkAssociationView(project_views.CreateNetworkAssociationView):
# class CreateRouterAssociationView(project_views.CreateRouterAssociationView):
# class DetailProjectView(project_views.DetailProjectView):
#     def _get_tenant_name(self, id):
#     def get_data(self):


from unittest import mock
from collections import namedtuple
from bgpvpn_dashboard.api import bgpvpn as bgpvpn_api
from bgpvpn_dashboard.dashboards.admin.bgpvpn import tables as bgpvpn_tables
from bgpvpn_dashboard.dashboards.admin.bgpvpn import views as bgpvpn_views
from openstack_dashboard.test import helpers

    def _get_mock_bgpvpn(self, prefix):
        bgpvpn_info = {}
        if prefix:
            bgpvpn_info = {
                "name": "%s_name" % prefix,
                "route_targets": [],
                "import_targets": [],
                "export_targets": [],
                "networks": [],
                "routers": [],
                "tenant_id": "tenant_id",
                "type": "l3"
            }
        return bgpvpn_api.Bgpvpn(bgpvpn_info)

    @mock.patch.object(bgpvpn_views.api, 'keystone', autospec=True)
    def test_get_tenant_name(self, mock_api):
        Tenant = namedtuple("Tenant", ["id", "name"])
        tenant = Tenant("tenant_id", "tenant_name")

        mock_api.tenant_get.return_value = tenant
        result = self.bgpvpn_view._get_tenant_name("tenant_id")

        mock_api.tenant_get.assert_called_once_with(
            self.bgpvpn_view.request, "tenant_id")
        self.assertEqual(result, "tenant_name")

    @mock.patch('%s.IndexView._get_tenant_name' % VIEWS,
                return_value={"tenant_id": "tenant_name"})

# Path: bgpvpn_dashboard/api/bgpvpn.py
# LOG = logging.getLogger(__name__)
# class Bgpvpn(neutron.NeutronAPIDictWrapper):
# class NetworkAssociation(neutron.NeutronAPIDictWrapper):
# class RouterAssociation(neutron.NeutronAPIDictWrapper):
# def bgpvpns_list(request, **kwargs):
# def bgpvpn_get(request, bgpvpn_id, **kwargs):
# def bgpvpn_create(request, **kwargs):
# def bgpvpn_update(request, bgpvpn_id, **kwargs):
# def bgpvpn_delete(request, bgpvpn_id):
# def network_association_get(request, bgpvpn_id, network_assoc_id, **kwargs):
# def network_association_list(request, bgpvpn_id, **kwargs):
# def network_association_create(request, bgpvpn_id, **kwargs):
# def network_association_delete(request, resource_id, bgpvpn_id):
# def router_association_get(request, bgpvpn_id, router_assoc_id, **kwargs):
# def router_association_list(request, bgpvpn_id, **kwargs):
# def router_association_create(request, bgpvpn_id, **kwargs):
# def router_association_update(request, bgpvpn_id, router_association_id,
#                               **kwargs):
# def router_association_delete(request, resource_id, bgpvpn_id):
# 
# Path: bgpvpn_dashboard/dashboards/admin/bgpvpn/tables.py
# LOG = logging.getLogger(__name__)
# class DeleteBgpvpn(policy.PolicyTargetMixin, tables.DeleteAction):
# class CreateBgpVpn(tables.LinkAction):
# class EditInfoBgpVpn(project_tables.EditInfoBgpVpn):
# class CreateNetworkAssociation(project_tables.CreateNetworkAssociation):
# class CreateRouterAssociation(project_tables.CreateRouterAssociation):
# class BgpvpnTable(project_tables.BgpvpnTable):
#     class Meta(object):
#     def action_present(count):
#     def action_past(count):
#     def delete(self, request, obj_id):
# def get_route_targets(bgpvpn):
# def get_import_targets(bgpvpn):
# def get_export_targets(bgpvpn):
# def get_network_url(network):
# def get_router_url(router):
# 
# Path: bgpvpn_dashboard/dashboards/admin/bgpvpn/views.py
# class IndexView(project_views.IndexView):
# class CreateView(forms.ModalFormView):
# class EditDataView(project_views.EditDataView):
# class CreateNetworkAssociationView(project_views.CreateNetworkAssociationView):
# class CreateRouterAssociationView(project_views.CreateRouterAssociationView):
# class DetailProjectView(project_views.DetailProjectView):
#     def _get_tenant_name(self, id):
#     def get_data(self):


# Path: bgpvpn_dashboard/test/admin/test_views.py
from unittest import mock
from collections import namedtuple
from bgpvpn_dashboard.api import bgpvpn as bgpvpn_api
from bgpvpn_dashboard.dashboards.admin.bgpvpn import tables as bgpvpn_tables
from bgpvpn_dashboard.dashboards.admin.bgpvpn import views as bgpvpn_views
from openstack_dashboard.test import helpers


    def _get_mock_bgpvpn(self, prefix):
        bgpvpn_info = {}
        if prefix:
            bgpvpn_info = {
                "name": "%s_name" % prefix,
                "route_targets": [],
                "import_targets": [],
                "export_targets": [],
                "networks": [],
                "routers": [],
                "tenant_id": "tenant_id",
                "type": "l3"
            }
        return bgpvpn_api.Bgpvpn(bgpvpn_info)

    @mock.patch.object(bgpvpn_views.api, 'keystone', autospec=True)
    def test_get_tenant_name(self, mock_api):
        Tenant = namedtuple("Tenant", ["id", "name"])
        tenant = Tenant("tenant_id", "tenant_name")

        mock_api.tenant_get.return_value = tenant
        result = self.bgpvpn_view._get_tenant_name("tenant_id")

        mock_api.tenant_get.assert_called_once_with(
            self.bgpvpn_view.request, "tenant_id")
        self.assertEqual(result, "tenant_name")

    @mock.patch('%s.IndexView._get_tenant_name' % VIEWS,
                return_value={"tenant_id": "tenant_name"})

    @mock.patch.object(bgpvpn_views, 'api', autospec=True)