def test_component_add_interface_method(self):
        oInterface1 = interface.create('Interface1')
        oInterface2 = interface.create('Interface2')
        oComponent = component.create('component')
        oComponent.add_interface(oInterface1)
        oComponent.add_interface(oInterface2)

        self.assertEqual(len(oComponent.interfaces), 2)
        self.assertEqual(oComponent.interfaces[0].name, 'Interface1')
        self.assertEqual(oComponent.interfaces[1].name, 'Interface2')
    def test_component_get_interface_named_method(self):
        oIntSource = interface.create('Interface1')
        oIntSink = interface.create('Interface2')
        oComponent = component.create('component')
        oComponent.add_interface(oIntSource)
        oComponent.add_interface(oIntSink)

        self.assertEqual(
            oComponent.get_interface_named('Interface1').name, 'Interface1')
        self.assertEqual(
            oComponent.get_interface_named('Interface2').name, 'Interface2')
        self.assertRaises(ValueError, oComponent.get_interface_named, 'Blah')
    def test_interface_parent_attribute(self):
        oIntSource = interface.create('Interface1')
        oIntSink = interface.create('Interface2')
        oComponent = component.create('component')
        oComponent.add_interface(oIntSource)
        oComponent.add_interface(oIntSink)

        self.assertEqual(
            oComponent.get_interface_named('Interface1').parent.name,
            'component')
        self.assertEqual(
            oComponent.get_interface_named('Interface2').parent.name,
            'component')
 def test_interface_class_attributes_exist(self):
     oInterface = interface.create('Interface1')
     self.assertEqual(oInterface.name, 'Interface1')
     self.assertEqual(oInterface.ports, None)
     self.assertEqual(oInterface.source, False)
     self.assertEqual(oInterface.parent, None)
     self.assertEqual(oInterface.path, None)
    def test_interface_add_port_method(self):
        oInterface = interface.create('Interface1')
        oInterface.add_port(port.create('Port1', 10, 'out', 'This is port 1'))
        oInterface.add_port(port.create('Port2', 5, 'in', 'This is port 2'))

        self.assertEqual(len(oInterface.ports), 2)
        self.assertEqual(oInterface.ports[0].name, 'Port1')
        self.assertEqual(oInterface.ports[1].name, 'Port2')
    def test_component_create_interface_method(self):
        oInterface1 = interface.create('Interface1')
        oInterface2 = interface.create('Interface2')
        oComponent = component.create('component')
        oInterface1 = oComponent.create_interface('Interface1')
        oInterface2 = oComponent.create_interface('Interface2')

        self.assertEqual(len(oComponent.interfaces), 2)
        self.assertEqual(oComponent.interfaces[0].name, 'Interface1')
        self.assertEqual(oComponent.interfaces[1].name, 'Interface2')
        self.assertEqual(oInterface1.name, 'Interface1')
        self.assertEqual(oInterface2.name, 'Interface2')

        oInterface1.name = 'New Interface1 Name'

        self.assertEqual(oComponent.interfaces[0].name, 'New Interface1 Name')
        self.assertEqual(oInterface1.name, 'New Interface1 Name')
    def test_get_number_ports_method(self):
        oInterface = interface.create('Interface1')

        self.assertEqual(oInterface.get_number_ports(), 0)

        oInterface.add_port(port.create('Port1', 10, 'out', 'This is port 1'))
        oInterface.add_port(port.create('Port2', 5, 'in', 'This is port 2'))

        self.assertEqual(oInterface.get_number_ports(), 15)

        oInterface.add_port(port.create('Port3', 3, 'in', 'This is port 3'))

        self.assertEqual(oInterface.get_number_ports(), 18)
    def test_interface_create_port_method(self):
        oInterface = interface.create('Interface1')

        oPort1 = oInterface.create_port('Port1', 10, 'out', 'This is port 1')
        oPort2 = oInterface.create_port('Port2', 5, 'in', 'This is port 2')

        self.assertEqual(len(oInterface.ports), 2)
        self.assertEqual(oInterface.ports[0].name, 'Port1')
        self.assertEqual(oInterface.ports[1].name, 'Port2')

        self.assertEqual(oPort1.name, 'Port1')
        self.assertEqual(oPort2.name, 'Port2')
        self.assertEqual(oPort1.description, 'This is port 1')
        self.assertEqual(oInterface.ports[0].description, 'This is port 1')

        oPort1.description = 'New port 1 description'

        self.assertEqual(oPort1.description, 'New port 1 description')
        self.assertEqual(oInterface.ports[0].description,
                         'New port 1 description')
 def create_interface(self, name):
     oInterface = interface.create(name)
     self.add_interface(oInterface)
     return oInterface