# Path: ebu_tt_live/carriage/interface.py
# class ICarriageMechanism(object):
# class IProducerCarriage(ICarriageMechanism):
# class IConsumerCarriage(ICarriageMechanism):
#     def expects(cls):
#     def register_producer_node(self, node):
#     def producer_node(self):
#     def emit_data(self, data, **kwargs):
#     def resume_producing(self):
#     def provides(cls):
#     def register_consumer_node(self, node):
#     def consumer_node(self):
#     def on_new_data(self, data, **kwargs):
# 
# Path: ebu_tt_live/carriage/base.py
# class AbstractCarriage(object):
# class AbstractProducerCarriage(IProducerCarriage, AbstractCarriage):
# class AbstractConsumerCarriage(IConsumerCarriage, AbstractCarriage):
# class AbstractCombinedCarriage(AbstractConsumerCarriage, AbstractProducerCarriage):
#     def is_document(self, document):
#     def register_producer_node(self, node):
#     def producer_node(self):
#     def resume_producing(self):
#     def register_consumer_node(self, node):
#     def consumer_node(self):
# 
# Path: ebu_tt_live/node/interface.py
# class INode(object):
# class IProducerNode(INode):
# class IConsumerNode(INode):
#     def process_document(self, document, **kwargs):
#     def resume_producing(self):
#     def provides(cls):
#     def producer_carriage(self):
#     def register_producer_carriage(self, producer_carriage):
#     def expects(cls):
#     def consumer_carriage(self):
#     def register_consumer_carriage(self, consumer_carriage):
# 
# Path: ebu_tt_live/errors.py
# class ComponentCompatError(TypeError):
#     pass
# 
# class DataCompatError(TypeError):
#     pass


from unittest import TestCase
from ebu_tt_live.carriage import interface as carriage_interface
from ebu_tt_live.carriage import base as carriage_base
from ebu_tt_live.node import interface as node_interface
from ebu_tt_live.errors import ComponentCompatError, DataCompatError
from mock import MagicMock

    def test_dummy_consumer_incompatible_interface(self):
        consumer_carriage = self._get_dummy_consumer_carriage(DummyDataTypeA)
        self.assertRaises(ComponentCompatError, consumer_carriage.register_consumer_node, self._producer_node)
        self.assertIsNone(consumer_carriage.consumer_node)

    def test_dummy_consumer_incompatible_data(self):
        consumer_carriage = self._get_dummy_consumer_carriage(DummyDataTypeB)
        self.assertRaises(DataCompatError, consumer_carriage.register_consumer_node, self._consumer_node)
        self.assertIsNone(consumer_carriage.consumer_node)
        
    def test_dummy_combined_success_with_producer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_producer_node(self._producer_node)
        self.assertEquals(combined_carriage.producer_node, self._producer_node)

    def test_dummy_combined_success_with_consumer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_consumer_node(self._consumer_node)
        self.assertEquals(combined_carriage.consumer_node, self._consumer_node)

    def test_dummy_combined_success_with_both(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_producer_node(self._producer_node)
        combined_carriage.register_consumer_node(self._consumer_node)
        self.assertEquals(combined_carriage.producer_node, self._producer_node)
        self.assertEquals(combined_carriage.consumer_node, self._consumer_node)

    def test_dummy_combined_incompatible_interface_with_consumer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)

# Path: ebu_tt_live/carriage/interface.py
# class ICarriageMechanism(object):
# class IProducerCarriage(ICarriageMechanism):
# class IConsumerCarriage(ICarriageMechanism):
#     def expects(cls):
#     def register_producer_node(self, node):
#     def producer_node(self):
#     def emit_data(self, data, **kwargs):
#     def resume_producing(self):
#     def provides(cls):
#     def register_consumer_node(self, node):
#     def consumer_node(self):
#     def on_new_data(self, data, **kwargs):
# 
# Path: ebu_tt_live/carriage/base.py
# class AbstractCarriage(object):
# class AbstractProducerCarriage(IProducerCarriage, AbstractCarriage):
# class AbstractConsumerCarriage(IConsumerCarriage, AbstractCarriage):
# class AbstractCombinedCarriage(AbstractConsumerCarriage, AbstractProducerCarriage):
#     def is_document(self, document):
#     def register_producer_node(self, node):
#     def producer_node(self):
#     def resume_producing(self):
#     def register_consumer_node(self, node):
#     def consumer_node(self):
# 
# Path: ebu_tt_live/node/interface.py
# class INode(object):
# class IProducerNode(INode):
# class IConsumerNode(INode):
#     def process_document(self, document, **kwargs):
#     def resume_producing(self):
#     def provides(cls):
#     def producer_carriage(self):
#     def register_producer_carriage(self, producer_carriage):
#     def expects(cls):
#     def consumer_carriage(self):
#     def register_consumer_carriage(self, consumer_carriage):
# 
# Path: ebu_tt_live/errors.py
# class ComponentCompatError(TypeError):
#     pass
# 
# class DataCompatError(TypeError):
#     pass


# Path: ebu_tt_live/carriage/test/test_base_carriage.py
from unittest import TestCase
from ebu_tt_live.carriage import interface as carriage_interface
from ebu_tt_live.carriage import base as carriage_base
from ebu_tt_live.node import interface as node_interface
from ebu_tt_live.errors import ComponentCompatError, DataCompatError
from mock import MagicMock


    def test_dummy_consumer_incompatible_interface(self):
        consumer_carriage = self._get_dummy_consumer_carriage(DummyDataTypeA)
        self.assertRaises(ComponentCompatError, consumer_carriage.register_consumer_node, self._producer_node)
        self.assertIsNone(consumer_carriage.consumer_node)

    def test_dummy_consumer_incompatible_data(self):
        consumer_carriage = self._get_dummy_consumer_carriage(DummyDataTypeB)
        self.assertRaises(DataCompatError, consumer_carriage.register_consumer_node, self._consumer_node)
        self.assertIsNone(consumer_carriage.consumer_node)
        
    def test_dummy_combined_success_with_producer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_producer_node(self._producer_node)
        self.assertEquals(combined_carriage.producer_node, self._producer_node)

    def test_dummy_combined_success_with_consumer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_consumer_node(self._consumer_node)
        self.assertEquals(combined_carriage.consumer_node, self._consumer_node)

    def test_dummy_combined_success_with_both(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)
        combined_carriage.register_producer_node(self._producer_node)
        combined_carriage.register_consumer_node(self._consumer_node)
        self.assertEquals(combined_carriage.producer_node, self._producer_node)
        self.assertEquals(combined_carriage.consumer_node, self._consumer_node)

    def test_dummy_combined_incompatible_interface_with_consumer(self):
        combined_carriage = self._get_dummy_combined_carriage(expects=DummyDataTypeA, provides=DummyDataTypeA)

        self.assertRaises(ComponentCompatError, combined_carriage.register_consumer_node, self._producer_node)