예제 #1
0
    def test_component(self):
        cont, comp = model.createInNewContainer("testscont", model.HwComponent,
                                          {"name":"MyHwComp", "role":"affected"})
        self.assertEqual(comp.name, "MyHwComp")

        cont2, comp2 = model.createInNewContainer("testscont2", model.HwComponent,
                                           {"name":"MyHwComp2", "role":"affecter"})
        self.assertEqual(comp2.name, "MyHwComp2")

        comp2.affects.value.append(comp)
        self.assertEqual(len(comp2.affects.value), 1)
        for c in comp2.affects.value:
            self.assertTrue(isinstance(c, model.ComponentBase))
            self.assertEqual(c.name, "MyHwComp")
            self.assertEqual(c.role, "affected")

        comp2_new = model.getObject("testscont2", "MyHwComp2")
        self.assertEqual(comp2_new.name, "MyHwComp2")
        self.assertEqual(len(comp2_new.affects.value), 1)

        comp.terminate()
        comp2.terminate()
        cont.terminate()
        cont2.terminate()
        time.sleep(0.1) # give it some time to terminate
예제 #2
0
 def test_component(self):
     comp = model.createInNewContainer("testscont", model.HwComponent, 
                                       {"name":"MyHwComp", "role":"affected"})
     self.assertEqual(comp.name, "MyHwComp")
         
     comp2 = model.createInNewContainer("testscont2", model.HwComponent, 
                                        {"name":"MyHwComp2", "role":"affecter"})
     self.assertEqual(comp2.name, "MyHwComp2")
     
     comp2._set_affects(set([comp]))
     self.assertEqual(len(comp2.affects), 1)
     for c in comp2.affects:
         self.assertTrue(isinstance(c, model.ComponentBase))
         self.assertEqual(c.name, "MyHwComp")
         self.assertEqual(c.role, "affected")
         
     comp2_new = model.getObject("testscont2", "MyHwComp2")
     self.assertEqual(comp2_new.name, "MyHwComp2")
     self.assertEqual(len(comp2_new.affects), 1)
         
     comp.terminate()
     comp2.terminate()
     model.getContainer("testscont").terminate()
     model.getContainer("testscont2").terminate()
     time.sleep(0.1) # give it some time to terminate
예제 #3
0
    def test_instantiate_simple_component(self):
        container, comp = model.createInNewContainer("testscont", FamilyValueComponent, {"name":"MyComp"})
        self.assertEqual(comp.name, "MyComp")

        comp_prime = model.getObject("testscont", "MyComp")
        self.assertEqual(comp_prime.name, "MyComp")

        comp.terminate()
        container.terminate()
예제 #4
0
    def test_instantiate_simple_component(self):
        container, comp = model.createInNewContainer("testscont", FamilyValueComponent, {"name":"MyComp"})
        self.assertEqual(comp.name, "MyComp")

        comp_prime = model.getObject("testscont", "MyComp")
        self.assertEqual(comp_prime.name, "MyComp")

        comp.terminate()
        container.terminate()
예제 #5
0
 def test_instantiate_component(self):
     comp = model.createInNewContainer("testcont", MyComponent, {"name":"MyComp"})
     self.assertEqual(comp.name, "MyComp")
     val = comp.my_value
     self.assertEqual(val, "ro", "Reading attribute failed")
     
     comp_prime = model.getObject("testcont", "MyComp")
     self.assertEqual(comp_prime.name, "MyComp")
     
     container = model.getContainer("testcont")
     container.ping()
     comp.terminate()
     container.terminate()
예제 #6
0
    def test_multi_components(self):
        container, comp = model.createInNewContainer("testmulti", FatherComponent, {"name":"Father", "children_num":3})
        self.assertEqual(comp.name, "Father")
        self.assertEqual(len(comp.children.value), 3, "Component should have 3 children")

        for child in comp.children.value:
            self.assertLess(child.value, 3)
            comp_direct = model.getObject("testmulti", child.name)
            self.assertEqual(comp_direct.name, child.name)
#            child.terminate()

        comp.terminate()
        # we are not terminating the children, but this should be caught by the container
        container.terminate()
예제 #7
0
    def test_multi_components(self):
        comp = model.createInNewContainer("testmulti", FatherComponent, {"name":"Father", "children_num":3})
        self.assertEqual(comp.name, "Father")
        self.assertEqual(len(comp.children), 3, "Component should have 3 children")
        
        for child in comp.children:
            self.assertLess(child.value, 3)
            comp_direct = model.getObject("testmulti", child.name)
            self.assertEqual(comp_direct.name, child.name)
#            child.terminate()
        
        comp.terminate()
        # we are not terminating the children, but this should be caught by the container
        model.getContainer("testmulti").terminate()
예제 #8
0
    def test_instantiate_component(self):
        comp = model.createInNewContainer("testcont", MyComponent,
                                          {"name": "MyComp"})
        self.assertEqual(comp.name, "MyComp")
        val = comp.my_value
        self.assertEqual(val, "ro", "Reading attribute failed")

        comp_prime = model.getObject("testcont", "MyComp")
        self.assertEqual(comp_prime.name, "MyComp")

        container = model.getContainer("testcont")
        container.ping()
        comp.terminate()
        container.terminate()