# Path: networking_odl/common/postcommit.py
# def postcommit(cls):
#     _build_methods(cls, *args)
#     return cls


from networking_odl.common import postcommit
from neutron.tests import base
class TestPostCommit(base.DietTestCase):
    def _get_class(self, *args):
        @postcommit.add_postcommit(*args)
        class TestClass(BaseTest):
            pass

        return TestClass

    def _get_methods_name(self, resources):
        ops = ['create', 'update', 'delete']
        m_names = [op + '_' + resource + '_postcommit' for op in ops
                   for resource in resources]

        return m_names

    def test_with_one_resource(self):
        cls = self._get_class('resource1')
        m_names = self._get_methods_name(['resource1'])
        for m_name in m_names:
            self.assertEqual(m_name, getattr(cls, m_name).__name__)

    def test_with_two_resource(self):
        cls = self._get_class('resource1', 'resource2')
        m_names = self._get_methods_name(['resource1', 'resource2'])
        for m_name in m_names:
            self.assertEqual(m_name, getattr(cls, m_name).__name__)

    def test_with_two_resource_create_defined_for_one(self):
        m_names = self._get_methods_name(['resource1', 'resource2'])


# Path: networking_odl/common/postcommit.py
# def postcommit(cls):
#     _build_methods(cls, *args)
#     return cls


# Path: networking_odl/tests/unit/common/test_postcommit.py
from networking_odl.common import postcommit
from neutron.tests import base

class TestPostCommit(base.DietTestCase):
    def _get_class(self, *args):
        @postcommit.add_postcommit(*args)
        class TestClass(BaseTest):
            pass

        return TestClass

    def _get_methods_name(self, resources):
        ops = ['create', 'update', 'delete']
        m_names = [op + '_' + resource + '_postcommit' for op in ops
                   for resource in resources]

        return m_names

    def test_with_one_resource(self):
        cls = self._get_class('resource1')
        m_names = self._get_methods_name(['resource1'])
        for m_name in m_names:
            self.assertEqual(m_name, getattr(cls, m_name).__name__)

    def test_with_two_resource(self):
        cls = self._get_class('resource1', 'resource2')
        m_names = self._get_methods_name(['resource1', 'resource2'])
        for m_name in m_names:
            self.assertEqual(m_name, getattr(cls, m_name).__name__)

    def test_with_two_resource_create_defined_for_one(self):
        m_names = self._get_methods_name(['resource1', 'resource2'])


        @postcommit.add_postcommit('resource1', 'resource2')