# Path: networking_odl/common/filters.py
# LOG = log.getLogger(__name__)
# _NETWORK_UNMAPPED_KEYS = ['qos_policy_id']
# _SUBNET_UNMAPPED_KEYS = ['segment_id', 'subnetpool_id']
# _PORT_UNMAPPED_KEYS = ['binding:profile', 'dns_name',
#                        'port_security_enabled', 'qos_policy_id']
# _FIP_UNMAPPED_KEYS = ['port_id', 'fixed_ip_address', 'router_id']
# _ODL_KNOWN_PROTOCOL_NAMES = (
#     n_const.PROTO_NAME_TCP,
#     n_const.PROTO_NAME_UDP,
#     n_const.PROTO_NAME_ICMP,
#     n_const.PROTO_NAME_IPV6_ICMP_LEGACY,
# )
# _FILTER_MAP = {
#     (odl_const.ODL_NETWORK, odl_const.ODL_CREATE): _filter_network_create,
#     (odl_const.ODL_NETWORK, odl_const.ODL_UPDATE): _filter_network_update,
#     (odl_const.ODL_SUBNET, odl_const.ODL_CREATE): _filter_subnet_create,
#     (odl_const.ODL_SUBNET, odl_const.ODL_UPDATE): _filter_subnet_update,
#     (odl_const.ODL_PORT, odl_const.ODL_CREATE): _filter_port_create,
#     (odl_const.ODL_PORT, odl_const.ODL_UPDATE): _filter_port_update,
#     (odl_const.ODL_ROUTER, odl_const.ODL_UPDATE): _filter_router_update,
#     (odl_const.ODL_SG_RULE, odl_const.ODL_CREATE): _filter_security_group_rule,
#     (odl_const.ODL_SG_RULE, odl_const.ODL_UPDATE): _filter_security_group_rule,
#     (odl_const.ODL_FLOATINGIP, odl_const.ODL_UPDATE): _filter_floatingip,
# }
# def _populate_project_id_and_tenant_id(resource_dict):
# def _filter_unmapped_null(resource_dict, unmapped_keys):
# def _filter_network_create(network):
# def _filter_network_update(network):
# def _filter_floatingip(fip):
# def _filter_subnet_create(subnet):
# def _filter_subnet_update(subnet):
# def _convert_value_to_str(dictionary, key):
# def _filter_port(port, attributes):
# def _filter_port_create(port):
# def _filter_port_update(port):
# def _filter_router_update(router):
# def _sgrule_scrub_icmpv6_name(sgrule):
# def _sgrule_scrub_unknown_protocol_name(protocol):
# def _filter_security_group_rule(sg_rule):
# def filter_for_odl(object_type, operation, data):


import copy
from unittest import mock
from neutron.tests import base
from neutron_lib import constants as n_const
from networking_odl.common import filters

    def test_populate_project_id_and_tenant_id_with_floatingip(self):
        # test case for OpenDaylightL3RouterPlugin.delete_floatingip()
        # it passes data as dependency_list as list, not dict.
        resource0 = ['router_uuid', 'floatingip_uuid']
        resource1 = resource0[:]
        filters._populate_project_id_and_tenant_id(resource1)
        self.assertEqual(resource0, resource1)

    def test_sgrule_scrub_unknown_protocol_name(self):
        KNOWN_PROTO_NAMES = (n_const.PROTO_NAME_TCP,
                             n_const.PROTO_NAME_UDP,
                             n_const.PROTO_NAME_ICMP,
                             n_const.PROTO_NAME_IPV6_ICMP_LEGACY)
        for protocol_name in KNOWN_PROTO_NAMES:
            self.assertEqual(
                protocol_name,
                filters._sgrule_scrub_unknown_protocol_name(protocol_name))

        self.assertEqual(
            n_const.PROTO_NUM_AH,
            filters._sgrule_scrub_unknown_protocol_name(n_const.PROTO_NAME_AH))
        self.assertEqual("1", filters._sgrule_scrub_unknown_protocol_name("1"))

    def test_sgrule_scrub_icmpv6_name(self):
        for protocol_name in (n_const.PROTO_NAME_ICMP,
                              n_const.PROTO_NAME_IPV6_ICMP,
                              n_const.PROTO_NAME_IPV6_ICMP_LEGACY):
            sgrule = {'ethertype': n_const.IPv6,
                      'protocol': protocol_name}

# Path: networking_odl/common/filters.py
# LOG = log.getLogger(__name__)
# _NETWORK_UNMAPPED_KEYS = ['qos_policy_id']
# _SUBNET_UNMAPPED_KEYS = ['segment_id', 'subnetpool_id']
# _PORT_UNMAPPED_KEYS = ['binding:profile', 'dns_name',
#                        'port_security_enabled', 'qos_policy_id']
# _FIP_UNMAPPED_KEYS = ['port_id', 'fixed_ip_address', 'router_id']
# _ODL_KNOWN_PROTOCOL_NAMES = (
#     n_const.PROTO_NAME_TCP,
#     n_const.PROTO_NAME_UDP,
#     n_const.PROTO_NAME_ICMP,
#     n_const.PROTO_NAME_IPV6_ICMP_LEGACY,
# )
# _FILTER_MAP = {
#     (odl_const.ODL_NETWORK, odl_const.ODL_CREATE): _filter_network_create,
#     (odl_const.ODL_NETWORK, odl_const.ODL_UPDATE): _filter_network_update,
#     (odl_const.ODL_SUBNET, odl_const.ODL_CREATE): _filter_subnet_create,
#     (odl_const.ODL_SUBNET, odl_const.ODL_UPDATE): _filter_subnet_update,
#     (odl_const.ODL_PORT, odl_const.ODL_CREATE): _filter_port_create,
#     (odl_const.ODL_PORT, odl_const.ODL_UPDATE): _filter_port_update,
#     (odl_const.ODL_ROUTER, odl_const.ODL_UPDATE): _filter_router_update,
#     (odl_const.ODL_SG_RULE, odl_const.ODL_CREATE): _filter_security_group_rule,
#     (odl_const.ODL_SG_RULE, odl_const.ODL_UPDATE): _filter_security_group_rule,
#     (odl_const.ODL_FLOATINGIP, odl_const.ODL_UPDATE): _filter_floatingip,
# }
# def _populate_project_id_and_tenant_id(resource_dict):
# def _filter_unmapped_null(resource_dict, unmapped_keys):
# def _filter_network_create(network):
# def _filter_network_update(network):
# def _filter_floatingip(fip):
# def _filter_subnet_create(subnet):
# def _filter_subnet_update(subnet):
# def _convert_value_to_str(dictionary, key):
# def _filter_port(port, attributes):
# def _filter_port_create(port):
# def _filter_port_update(port):
# def _filter_router_update(router):
# def _sgrule_scrub_icmpv6_name(sgrule):
# def _sgrule_scrub_unknown_protocol_name(protocol):
# def _filter_security_group_rule(sg_rule):
# def filter_for_odl(object_type, operation, data):


# Path: networking_odl/tests/unit/common/test_filters.py
import copy
from unittest import mock
from neutron.tests import base
from neutron_lib import constants as n_const
from networking_odl.common import filters


    def test_populate_project_id_and_tenant_id_with_floatingip(self):
        # test case for OpenDaylightL3RouterPlugin.delete_floatingip()
        # it passes data as dependency_list as list, not dict.
        resource0 = ['router_uuid', 'floatingip_uuid']
        resource1 = resource0[:]
        filters._populate_project_id_and_tenant_id(resource1)
        self.assertEqual(resource0, resource1)

    def test_sgrule_scrub_unknown_protocol_name(self):
        KNOWN_PROTO_NAMES = (n_const.PROTO_NAME_TCP,
                             n_const.PROTO_NAME_UDP,
                             n_const.PROTO_NAME_ICMP,
                             n_const.PROTO_NAME_IPV6_ICMP_LEGACY)
        for protocol_name in KNOWN_PROTO_NAMES:
            self.assertEqual(
                protocol_name,
                filters._sgrule_scrub_unknown_protocol_name(protocol_name))

        self.assertEqual(
            n_const.PROTO_NUM_AH,
            filters._sgrule_scrub_unknown_protocol_name(n_const.PROTO_NAME_AH))
        self.assertEqual("1", filters._sgrule_scrub_unknown_protocol_name("1"))

    def test_sgrule_scrub_icmpv6_name(self):
        for protocol_name in (n_const.PROTO_NAME_ICMP,
                              n_const.PROTO_NAME_IPV6_ICMP,
                              n_const.PROTO_NAME_IPV6_ICMP_LEGACY):
            sgrule = {'ethertype': n_const.IPv6,
                      'protocol': protocol_name}

            filters._sgrule_scrub_icmpv6_name(sgrule)