# 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 _check_id(self, resource, project_id):
        filters._populate_project_id_and_tenant_id(resource)
        self.assertIn(resource['project_id'], project_id)
        self.assertIn(resource['tenant_id'], project_id)

    def _test_populate_project_id_and_tenant_id(self, project_id):
        self._check_id({'project_id': project_id}, project_id)
        self._check_id({'tenant_id': project_id}, project_id)
        self._check_id({'project_id': project_id,
                        'tenant_id': project_id}, project_id)

    def test_populate_project_id_and_tenant_id_with_id(self):
        self._test_populate_project_id_and_tenant_id(
            '01234567-890a-bcde-f012-3456789abcde')
        self._test_populate_project_id_and_tenant_id("")

    def test_populate_project_id_and_tenant_id_without_id(self):
        resource = {}
        filters._populate_project_id_and_tenant_id(resource)
        self.assertNotIn('project_id', resource)
        self.assertNotIn('tenant_id', resource)

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


# 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 _check_id(self, resource, project_id):
        filters._populate_project_id_and_tenant_id(resource)
        self.assertIn(resource['project_id'], project_id)
        self.assertIn(resource['tenant_id'], project_id)

    def _test_populate_project_id_and_tenant_id(self, project_id):
        self._check_id({'project_id': project_id}, project_id)
        self._check_id({'tenant_id': project_id}, project_id)
        self._check_id({'project_id': project_id,
                        'tenant_id': project_id}, project_id)

    def test_populate_project_id_and_tenant_id_with_id(self):
        self._test_populate_project_id_and_tenant_id(
            '01234567-890a-bcde-f012-3456789abcde')
        self._test_populate_project_id_and_tenant_id("")

    def test_populate_project_id_and_tenant_id_without_id(self):
        resource = {}
        filters._populate_project_id_and_tenant_id(resource)
        self.assertNotIn('project_id', resource)
        self.assertNotIn('tenant_id', resource)

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


    def test_populate_project_id_and_tenant_id_with_floatingip(self):