# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/apic_sync.py
# LOG = logging.getLogger(__name__)
# class SynchronizerBase(object):
# class ApicBaseSynchronizer(SynchronizerBase):
# class ApicRouterSynchronizer(SynchronizerBase):
#     def __init__(self, driver, interval=None):
#     def sync(self, f, *args, **kwargs):
#     def sync_base(self):
#     def _sync_base(self):
#     def sync_router(self):
#     def _sync_router(self):
# 
# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/constants.py
# AGENT_TYPE_DVS = 'DVS agent'
# APIC_SYNC_NETWORK = 'apic-sync-network'
# HOST_SNAT_NETWORK_PREFIX = 'host-snat-network-for-internal-use-'
# HOST_SNAT_POOL = 'host-snat-pool-for-internal-use'
# HOST_SNAT_POOL_PORT = 'host-snat-pool-port-for-internal-use'
# DEVICE_OWNER_SNAT_PORT = 'host-snat-pool-port-device-owner-internal-use'
# VIF_TYPE_DVS = "dvs"


import sys
import mock
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import apic_sync
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import constants as acst
from neutron.tests import base
        self.get_admin_context = mock.patch(GET_ADMIN_CONTEXT).start()
        self.get_admin_context.return_value = mock.Mock()
        # Patch get locked port and binding
        self.get_locked_port_and_binding = mock.patch(L2_DB).start()
        self.get_locked_port_and_binding.return_value = [mock.Mock()] * 2
        # Patch driver context
        mock.patch(NETWORK_CONTEXT).start()
        mock.patch(SUBNET_CONTEXT).start()
        mock.patch(PORT_CONTEXT).start()

    def test_sync_base(self):
        sync = apic_sync.ApicBaseSynchronizer(self.driver)
        sync.core_plugin = mock.Mock()
        sync.core_plugin.get_networks.return_value = [
            {'id': 'net1', 'name': 'some'},
            {'id': 'net2', 'name': acst.APIC_SYNC_NETWORK},
            {'id': 'net3', 'name': acst.HOST_SNAT_NETWORK_PREFIX + 'asasa'}]
        sync.core_plugin.get_subnets.return_value = [
            {'id': 'sub', 'name': 'some', 'network_id': 'net1'}]
        sync.core_plugin.get_ports.return_value = [
            {'id': 'port', 'network_id': 'net', 'name': 'some'}]
        sync.core_plugin.get_network.return_value = {'id': 'net1',
                                                     'name': 'some'}
        sync._sync_base()
        self.assertEqual(1, self.driver.create_network_postcommit.call_count)
        self.assertEqual(1, self.driver.create_subnet_postcommit.call_count)
        self.assertEqual(1, self.get_locked_port_and_binding.call_count)
        self.assertEqual(1, self.driver.create_port_postcommit.call_count)

    def test_sync_router(self):

# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/apic_sync.py
# LOG = logging.getLogger(__name__)
# class SynchronizerBase(object):
# class ApicBaseSynchronizer(SynchronizerBase):
# class ApicRouterSynchronizer(SynchronizerBase):
#     def __init__(self, driver, interval=None):
#     def sync(self, f, *args, **kwargs):
#     def sync_base(self):
#     def _sync_base(self):
#     def sync_router(self):
#     def _sync_router(self):
# 
# Path: apic_ml2/neutron/plugins/ml2/drivers/cisco/apic/constants.py
# AGENT_TYPE_DVS = 'DVS agent'
# APIC_SYNC_NETWORK = 'apic-sync-network'
# HOST_SNAT_NETWORK_PREFIX = 'host-snat-network-for-internal-use-'
# HOST_SNAT_POOL = 'host-snat-pool-for-internal-use'
# HOST_SNAT_POOL_PORT = 'host-snat-pool-port-for-internal-use'
# DEVICE_OWNER_SNAT_PORT = 'host-snat-pool-port-device-owner-internal-use'
# VIF_TYPE_DVS = "dvs"


# Path: apic_ml2/neutron/tests/unit/ml2/drivers/cisco/apic/test_cisco_apic_sync.py
import sys
import mock
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import apic_sync
from apic_ml2.neutron.plugins.ml2.drivers.cisco.apic import constants as acst
from neutron.tests import base

        self.get_admin_context = mock.patch(GET_ADMIN_CONTEXT).start()
        self.get_admin_context.return_value = mock.Mock()
        # Patch get locked port and binding
        self.get_locked_port_and_binding = mock.patch(L2_DB).start()
        self.get_locked_port_and_binding.return_value = [mock.Mock()] * 2
        # Patch driver context
        mock.patch(NETWORK_CONTEXT).start()
        mock.patch(SUBNET_CONTEXT).start()
        mock.patch(PORT_CONTEXT).start()

    def test_sync_base(self):
        sync = apic_sync.ApicBaseSynchronizer(self.driver)
        sync.core_plugin = mock.Mock()
        sync.core_plugin.get_networks.return_value = [
            {'id': 'net1', 'name': 'some'},
            {'id': 'net2', 'name': acst.APIC_SYNC_NETWORK},
            {'id': 'net3', 'name': acst.HOST_SNAT_NETWORK_PREFIX + 'asasa'}]
        sync.core_plugin.get_subnets.return_value = [
            {'id': 'sub', 'name': 'some', 'network_id': 'net1'}]
        sync.core_plugin.get_ports.return_value = [
            {'id': 'port', 'network_id': 'net', 'name': 'some'}]
        sync.core_plugin.get_network.return_value = {'id': 'net1',
                                                     'name': 'some'}
        sync._sync_base()
        self.assertEqual(1, self.driver.create_network_postcommit.call_count)
        self.assertEqual(1, self.driver.create_subnet_postcommit.call_count)
        self.assertEqual(1, self.get_locked_port_and_binding.call_count)
        self.assertEqual(1, self.driver.create_port_postcommit.call_count)

    def test_sync_router(self):

        sync = apic_sync.ApicRouterSynchronizer(self.driver)