# Path: networking_odl/ml2/legacy_port_binding.py
# LOG = log.getLogger(__name__)
# class LegacyPortBindingManager(port_binding.PortBindingController):
#     def __init__(self):
#     def bind_port(self, port_context):
#     def _check_segment(self, segment):
#     def _get_vif_type(self, port_context):
# 
# Path: networking_odl/tests/base.py
# class DietTestCase(base.DietTestCase):
# class OpenDaylightRestClientFixture(fixtures.Fixture):
# class OpenDaylightRestClientGlobalFixture(fixtures.Fixture):
# class OpenDaylightFeaturesFixture(fixtures.Fixture):
# class OpenDaylightJournalThreadFixture(fixtures.Fixture):
# class JournalWorkerPidFileFixture(fixtures.Fixture):
# class OpenDaylightPeriodicTaskFixture(fixtures.Fixture):
# class OpenDaylightPseudoAgentPrePopulateFixture(
#         nl_fixture.CallbackRegistryFixture):
# class OpenDaylightFullSyncFixture(fixtures.Fixture):
#     def patch(self, target, name, *args, **kwargs):
#     def _setUp(self):
#     def __init__(self, global_client):
#     def _setUp(self):
#     def _setUp(self):
#     def _setUp(self):
#     def remock_atexit(self):
#     def _setUp(self):
#     def _setUp(self):
#     def _setUp(self):
#     def _restore(self):
#     def _setUp(self):


from unittest import mock
from neutron.plugins.ml2 import driver_context as ctx
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as n_constants
from neutron_lib.plugins.ml2 import api
from networking_odl.ml2 import legacy_port_binding
from networking_odl.tests import base
        api.PHYSICAL_NETWORK: 'API_PHYSICAL_NETWORK'}

    def test_check_segment(self):
        """Validate the _check_segment method."""

        all_network_types = [n_constants.TYPE_FLAT, n_constants.TYPE_GRE,
                             n_constants.TYPE_LOCAL, n_constants.TYPE_VXLAN,
                             n_constants.TYPE_VLAN, n_constants.TYPE_NONE]

        mgr = legacy_port_binding.LegacyPortBindingManager()

        valid_types = {
            network_type
            for network_type in all_network_types
            if mgr._check_segment({api.NETWORK_TYPE: network_type})}

        self.assertEqual({
            n_constants.TYPE_FLAT, n_constants.TYPE_LOCAL,
            n_constants.TYPE_GRE, n_constants.TYPE_VXLAN,
            n_constants.TYPE_VLAN}, valid_types)

    def test_bind_port(self):

        network = mock.MagicMock(spec=api.NetworkContext)

        port_context = mock.MagicMock(
            spec=ctx.PortContext, current={'id': 'CURRENT_CONTEXT_ID'},
            segments_to_bind=[self.valid_segment, self.invalid_segment],
            network=network)


# Path: networking_odl/ml2/legacy_port_binding.py
# LOG = log.getLogger(__name__)
# class LegacyPortBindingManager(port_binding.PortBindingController):
#     def __init__(self):
#     def bind_port(self, port_context):
#     def _check_segment(self, segment):
#     def _get_vif_type(self, port_context):
# 
# Path: networking_odl/tests/base.py
# class DietTestCase(base.DietTestCase):
# class OpenDaylightRestClientFixture(fixtures.Fixture):
# class OpenDaylightRestClientGlobalFixture(fixtures.Fixture):
# class OpenDaylightFeaturesFixture(fixtures.Fixture):
# class OpenDaylightJournalThreadFixture(fixtures.Fixture):
# class JournalWorkerPidFileFixture(fixtures.Fixture):
# class OpenDaylightPeriodicTaskFixture(fixtures.Fixture):
# class OpenDaylightPseudoAgentPrePopulateFixture(
#         nl_fixture.CallbackRegistryFixture):
# class OpenDaylightFullSyncFixture(fixtures.Fixture):
#     def patch(self, target, name, *args, **kwargs):
#     def _setUp(self):
#     def __init__(self, global_client):
#     def _setUp(self):
#     def _setUp(self):
#     def _setUp(self):
#     def remock_atexit(self):
#     def _setUp(self):
#     def _setUp(self):
#     def _setUp(self):
#     def _restore(self):
#     def _setUp(self):


# Path: networking_odl/tests/unit/ml2/test_legacy_port_binding.py
from unittest import mock
from neutron.plugins.ml2 import driver_context as ctx
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as n_constants
from neutron_lib.plugins.ml2 import api
from networking_odl.ml2 import legacy_port_binding
from networking_odl.tests import base

        api.PHYSICAL_NETWORK: 'API_PHYSICAL_NETWORK'}

    def test_check_segment(self):
        """Validate the _check_segment method."""

        all_network_types = [n_constants.TYPE_FLAT, n_constants.TYPE_GRE,
                             n_constants.TYPE_LOCAL, n_constants.TYPE_VXLAN,
                             n_constants.TYPE_VLAN, n_constants.TYPE_NONE]

        mgr = legacy_port_binding.LegacyPortBindingManager()

        valid_types = {
            network_type
            for network_type in all_network_types
            if mgr._check_segment({api.NETWORK_TYPE: network_type})}

        self.assertEqual({
            n_constants.TYPE_FLAT, n_constants.TYPE_LOCAL,
            n_constants.TYPE_GRE, n_constants.TYPE_VXLAN,
            n_constants.TYPE_VLAN}, valid_types)

    def test_bind_port(self):

        network = mock.MagicMock(spec=api.NetworkContext)

        port_context = mock.MagicMock(
            spec=ctx.PortContext, current={'id': 'CURRENT_CONTEXT_ID'},
            segments_to_bind=[self.valid_segment, self.invalid_segment],
            network=network)


        mgr = legacy_port_binding.LegacyPortBindingManager()