Ejemplo n.º 1
0
    def test_system_add_component_method(self):
        oSystem = system.create('System1')
        oSystem.add_component(component.create('Component1', 'Component1'))
        oSystem.add_component(component.create('Component2', 'Component2'))
        oComponent3 = oSystem.add_component(component.create('Component3', 'Component3'))

        self.assertEqual(len(oSystem.components), 3)
        self.assertEqual(oSystem.components[0].name, 'Component1')
        self.assertEqual(oSystem.components[1].name, 'Component2')
        self.assertEqual(oSystem.components[2].name, 'Component3')
        self.assertEqual(oComponent3, oSystem.components[2])
 def test_component_class_attributes_exist(self):
     oComponent = component.create('component1')
     self.assertEqual(oComponent.name, 'component1')
     self.assertEqual(oComponent.interfaces, None)
     self.assertEqual(oComponent.datasheet, None)
     self.assertEqual(oComponent.instanceName, None)
     self.assertEqual(oComponent.type, 'component')
    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')
Ejemplo n.º 4
0
    def test_get_component_named_method(self):
        oSystem = system.create('System1')
        oCca = oSystem.add_component(de.hw.cca.create('CCA'))
        oCca2 = oCca.add_component(de.hw.cca.create('CCA2'))
        oComponent1 = oCca.add_component(component.create('Component1', 'Component1'))
        oComponent2 = oCca.add_component(component.create('Component2', 'Component2'))
        oComponent3 = oCca.add_component(component.create('Component3', 'Component3'))
        oComponent4 = oCca2.add_component(component.create('Component4', 'Component4'))

        self.assertEqual(oCca.get_component_named('Component1'), oComponent1)
        self.assertEqual(oCca.get_component_named('Component2'), oComponent2)
        self.assertEqual(oCca.get_component_named('Component3'), oComponent3)
        self.assertRaises(ValueError, oCca.get_component_named,'Comp1')

        self.assertEqual(oSystem.get_component_named('CCA.Component1'), oComponent1)
        self.assertEqual(oSystem.get_component_named('CCA.Component2'), oComponent2)
        self.assertEqual(oSystem.get_component_named('CCA.Component3'), oComponent3)
        self.assertEqual(oSystem.get_component_named('CCA.CCA2.Component4'), oComponent4)
        self.assertRaises(ValueError, oSystem.get_component_named,'CCA.CCA2.Component5')
        self.assertRaises(ValueError, oSystem.get_component_named,'CCA.Component5')
    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_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_component_datasheet_attribute(self):
     oComponent = component.create('component1')
     oComponent.datasheet = 'datasheet url'
     self.assertEqual(oComponent.datasheet, 'datasheet url')