# Path: openelex/base/transform.py
# class Transform(object):
# class FunctionWrappingTransform(Transform):
# class Registry(StateBase):
#     def __init__(self):
#     def add_validation(self, *validators):
#     def validators(self):
#     def __str__(self):
#     def __call__(self):
#     def reverse(self):
#     def __init__(self, func):
#     def name(self):
#     def __call__(self):
#     def register(self, state, transform, validators=[], raw=False):
#     def get(self, state, name, raw=False):
#     def all(self, state, raw=False):
#     def _get_registry(self, raw=False):


from unittest import TestCase
from mock import Mock
from openelex.base.transform import registry



class TestTransformRegistry(TestCase):
    def test_register_with_validators(self):
        mock_transform = Mock(return_value=None)
        mock_transform.__name__ = 'mock_transform'
        mock_validator1 = Mock(return_value=None)
        mock_validator1.__name__ = 'mock_validator1'
        mock_validator2 = Mock(return_value=None)
        mock_validator2.__name__ = 'mock_validator2'

        validators = [mock_validator1, mock_validator2]

        registry.register("XX", mock_transform, validators) 

        transform = registry.get("XX", "mock_transform")
        self.assertEqual(list(transform.validators.values()), validators)

        transform()
        mock_transform.assert_called_once_with()

    def test_register_raw(self):
        mock_transform = Mock(return_value=None)
        mock_transform.__name__ = 'mock_transform'


# Path: openelex/base/transform.py
# class Transform(object):
# class FunctionWrappingTransform(Transform):
# class Registry(StateBase):
#     def __init__(self):
#     def add_validation(self, *validators):
#     def validators(self):
#     def __str__(self):
#     def __call__(self):
#     def reverse(self):
#     def __init__(self, func):
#     def name(self):
#     def __call__(self):
#     def register(self, state, transform, validators=[], raw=False):
#     def get(self, state, name, raw=False):
#     def all(self, state, raw=False):
#     def _get_registry(self, raw=False):


# Path: openelex/tests/test_transform_registry.py
from unittest import TestCase
from mock import Mock
from openelex.base.transform import registry




class TestTransformRegistry(TestCase):
    def test_register_with_validators(self):
        mock_transform = Mock(return_value=None)
        mock_transform.__name__ = 'mock_transform'
        mock_validator1 = Mock(return_value=None)
        mock_validator1.__name__ = 'mock_validator1'
        mock_validator2 = Mock(return_value=None)
        mock_validator2.__name__ = 'mock_validator2'

        validators = [mock_validator1, mock_validator2]

        registry.register("XX", mock_transform, validators) 

        transform = registry.get("XX", "mock_transform")
        self.assertEqual(list(transform.validators.values()), validators)

        transform()
        mock_transform.assert_called_once_with()

    def test_register_raw(self):
        mock_transform = Mock(return_value=None)
        mock_transform.__name__ = 'mock_transform'


        registry.register("XX", mock_transform, raw=True)