# Path: networking_sfc/services/flowclassifier/common/context.py
# class FlowClassifierPluginContext():
# class FlowClassifierContext(FlowClassifierPluginContext):
#     def __init__(self, plugin, plugin_context):
#     def __init__(self, plugin, plugin_context, flowclassifier,
#                  original_flowclassifier=None):
#     def current(self):
#     def original(self):
# 
# Path: networking_sfc/services/flowclassifier/common/exceptions.py
# class FlowClassifierDriverError(exceptions.NeutronException):
# class FlowClassifierException(exceptions.NeutronException):
# class FlowClassifierBadRequest(exceptions.BadRequest, FlowClassifierException):
# 
# Path: networking_sfc/tests/unit/db/test_flowclassifier_db.py
# DB_FLOWCLASSIFIER_PLUGIN_CLASS = (
#     "networking_sfc.db.flowclassifier_db.FlowClassifierDbPlugin"
# )
# class FlowClassifierDbPluginTestCaseBase(base.BaseTestCase):
# class FlowClassifierDbPluginTestCase(
#     base.NeutronDbPluginV2TestCase,
#     FlowClassifierDbPluginTestCaseBase
# ):
#     def _create_flow_classifier(
#         self, fmt, flow_classifier=None, expected_res_status=None, **kwargs
#     ):
#     def flow_classifier(
#         self, fmt=None, flow_classifier=None, do_delete=True, **kwargs
#     ):
#     def _get_expected_flow_classifier(self, flow_classifier):
#     def _assert_flow_classifiers_match_subsets(self, flow_classifiers,
#                                                subsets, sort_key=None):
#     def _test_create_flow_classifier(
#         self, flow_classifier, expected_flow_classifier=None
#     ):
#     def setUp(self, core_plugin=None, flowclassifier_plugin=None,
#               ext_mgr=None):
#     def test_create_flow_classifier(self):
#     def test_create_flow_classifier_with_logical_destination_port(self):
#     def test_quota_create_flow_classifier(self):
#     def test_create_flow_classifier_with_all_fields(self):
#     def test_create_flow_classifier_with_all_supported_ethertype(self):
#     def test_create_flow_classifier_with_invalid_ethertype(self):
#     def test_create_flow_classifier_with_all_supported_protocol(self):
#     def test_create_flow_classifier_with_invalid_protocol(self):
#     def test_create_flow_classifier_with_all_supported_port_protocol(self):
#     def test_create_flow_classifier_with_invalid_ip_prefix_ethertype(self):
#     def test_create_flow_classifier_with_invalid_port_protocol(self):
#     def test_create_flow_classifier_with_all_supported_ip_prefix(self):
#     def test_create_flow_classifier_with_invalid_ip_prefix(self):
#     def test_create_flow_classifier_with_all_supported_l7_parameters(self):
#     def test_create_flow_classifier_with_invalid_l7_parameters(self):
#     def test_create_flow_classifier_with_port_id(self):
#     def test_create_flow_classifier_with_nouuid_port_id(self):
#     def test_create_flow_classifier_ethertype_conflict(self):
#     def test_create_flow_classifier_protocol_conflict(self):
#     def test_create_flow_classifier_source_ip_prefix_conflict(self):
#     def test_create_flow_classifier_destination_ip_prefix_conflict(self):
#     def test_create_flow_classifier_source_port_range_conflict(self):
#     def test_create_flow_classifier_destination_port_range_conflict(self):
#     def test_create_flow_classifier_not_all_fields_conflict(self):
#     def test_create_flow_classifier_with_unknown_port_id(self):
#     def test_list_flow_classifiers(self):
#     def test_list_flow_classifiers_with_params(self):
#     def test_list_flow_classifiers_with_unknown_params(self):
#     def test_show_flow_classifier(self):
#     def test_show_flow_classifier_noexist(self):
#     def test_update_flow_classifier(self):
#     def _test_update_with_field(
#         self, fc, updates, expected_status_code
#     ):
#     def test_update_flow_classifer_unsupported_fields(self):
#     def test_delete_flow_classifier(self):
#     def test_delete_flow_classifier_noexist(self):


import copy
from unittest import mock
from networking_sfc.services.flowclassifier.common import context as fc_ctx
from networking_sfc.services.flowclassifier.common import exceptions as fc_exc
from networking_sfc.tests.unit.db import test_flowclassifier_db
            ext_mgr=ext_mgr
        )

    def _record_context(self, plugin_context):
        self.plugin_context = plugin_context

    def _record_context_precommit(self, plugin_context):
        self.plugin_context_precommit = plugin_context

    def _record_context_postcommit(self, plugin_context):
        self.plugin_context_postcommit = plugin_context

    def test_create_flow_classifier_driver_manager_called(self):
        self.fake_driver_manager.create_flow_classifier_precommit = mock.Mock(
            side_effect=self._record_context_precommit)
        self.fake_driver_manager.create_flow_classifier_postcommit = mock.Mock(
            side_effect=self._record_context_postcommit)
        with self.port(
            name='test1'
        ) as port:
            with self.flow_classifier(flow_classifier={
                'logical_source_port': port['port']['id']
            }) as fc:
                driver_manager = self.fake_driver_manager
                (driver_manager.create_flow_classifier_precommit
                 .assert_called_once_with(mock.ANY))
                (driver_manager.create_flow_classifier_postcommit
                 .assert_called_once_with(mock.ANY))
                self.assertIsInstance(
                    self.plugin_context_precommit,

# Path: networking_sfc/services/flowclassifier/common/context.py
# class FlowClassifierPluginContext():
# class FlowClassifierContext(FlowClassifierPluginContext):
#     def __init__(self, plugin, plugin_context):
#     def __init__(self, plugin, plugin_context, flowclassifier,
#                  original_flowclassifier=None):
#     def current(self):
#     def original(self):
# 
# Path: networking_sfc/services/flowclassifier/common/exceptions.py
# class FlowClassifierDriverError(exceptions.NeutronException):
# class FlowClassifierException(exceptions.NeutronException):
# class FlowClassifierBadRequest(exceptions.BadRequest, FlowClassifierException):
# 
# Path: networking_sfc/tests/unit/db/test_flowclassifier_db.py
# DB_FLOWCLASSIFIER_PLUGIN_CLASS = (
#     "networking_sfc.db.flowclassifier_db.FlowClassifierDbPlugin"
# )
# class FlowClassifierDbPluginTestCaseBase(base.BaseTestCase):
# class FlowClassifierDbPluginTestCase(
#     base.NeutronDbPluginV2TestCase,
#     FlowClassifierDbPluginTestCaseBase
# ):
#     def _create_flow_classifier(
#         self, fmt, flow_classifier=None, expected_res_status=None, **kwargs
#     ):
#     def flow_classifier(
#         self, fmt=None, flow_classifier=None, do_delete=True, **kwargs
#     ):
#     def _get_expected_flow_classifier(self, flow_classifier):
#     def _assert_flow_classifiers_match_subsets(self, flow_classifiers,
#                                                subsets, sort_key=None):
#     def _test_create_flow_classifier(
#         self, flow_classifier, expected_flow_classifier=None
#     ):
#     def setUp(self, core_plugin=None, flowclassifier_plugin=None,
#               ext_mgr=None):
#     def test_create_flow_classifier(self):
#     def test_create_flow_classifier_with_logical_destination_port(self):
#     def test_quota_create_flow_classifier(self):
#     def test_create_flow_classifier_with_all_fields(self):
#     def test_create_flow_classifier_with_all_supported_ethertype(self):
#     def test_create_flow_classifier_with_invalid_ethertype(self):
#     def test_create_flow_classifier_with_all_supported_protocol(self):
#     def test_create_flow_classifier_with_invalid_protocol(self):
#     def test_create_flow_classifier_with_all_supported_port_protocol(self):
#     def test_create_flow_classifier_with_invalid_ip_prefix_ethertype(self):
#     def test_create_flow_classifier_with_invalid_port_protocol(self):
#     def test_create_flow_classifier_with_all_supported_ip_prefix(self):
#     def test_create_flow_classifier_with_invalid_ip_prefix(self):
#     def test_create_flow_classifier_with_all_supported_l7_parameters(self):
#     def test_create_flow_classifier_with_invalid_l7_parameters(self):
#     def test_create_flow_classifier_with_port_id(self):
#     def test_create_flow_classifier_with_nouuid_port_id(self):
#     def test_create_flow_classifier_ethertype_conflict(self):
#     def test_create_flow_classifier_protocol_conflict(self):
#     def test_create_flow_classifier_source_ip_prefix_conflict(self):
#     def test_create_flow_classifier_destination_ip_prefix_conflict(self):
#     def test_create_flow_classifier_source_port_range_conflict(self):
#     def test_create_flow_classifier_destination_port_range_conflict(self):
#     def test_create_flow_classifier_not_all_fields_conflict(self):
#     def test_create_flow_classifier_with_unknown_port_id(self):
#     def test_list_flow_classifiers(self):
#     def test_list_flow_classifiers_with_params(self):
#     def test_list_flow_classifiers_with_unknown_params(self):
#     def test_show_flow_classifier(self):
#     def test_show_flow_classifier_noexist(self):
#     def test_update_flow_classifier(self):
#     def _test_update_with_field(
#         self, fc, updates, expected_status_code
#     ):
#     def test_update_flow_classifer_unsupported_fields(self):
#     def test_delete_flow_classifier(self):
#     def test_delete_flow_classifier_noexist(self):


# Path: networking_sfc/tests/unit/services/flowclassifier/test_plugin.py
import copy
from unittest import mock
from networking_sfc.services.flowclassifier.common import context as fc_ctx
from networking_sfc.services.flowclassifier.common import exceptions as fc_exc
from networking_sfc.tests.unit.db import test_flowclassifier_db

            ext_mgr=ext_mgr
        )

    def _record_context(self, plugin_context):
        self.plugin_context = plugin_context

    def _record_context_precommit(self, plugin_context):
        self.plugin_context_precommit = plugin_context

    def _record_context_postcommit(self, plugin_context):
        self.plugin_context_postcommit = plugin_context

    def test_create_flow_classifier_driver_manager_called(self):
        self.fake_driver_manager.create_flow_classifier_precommit = mock.Mock(
            side_effect=self._record_context_precommit)
        self.fake_driver_manager.create_flow_classifier_postcommit = mock.Mock(
            side_effect=self._record_context_postcommit)
        with self.port(
            name='test1'
        ) as port:
            with self.flow_classifier(flow_classifier={
                'logical_source_port': port['port']['id']
            }) as fc:
                driver_manager = self.fake_driver_manager
                (driver_manager.create_flow_classifier_precommit
                 .assert_called_once_with(mock.ANY))
                (driver_manager.create_flow_classifier_postcommit
                 .assert_called_once_with(mock.ANY))
                self.assertIsInstance(
                    self.plugin_context_precommit,

                    fc_ctx.FlowClassifierContext)