Esempio n. 1
0
    def test_import_source(self):
        from libcellml import Issue, ImportSource

        # ImportSourcePtr importSource()
        e = Issue()
        self.assertIsNone(e.component())
        name = 'uri'
        i = ImportSource()
        i.setId(name)
        e.setImportSource(i)
        self.assertIsInstance(e.importSource(), ImportSource)
        self.assertEqual(e.importSource().id(), name)
Esempio n. 2
0
    def test_get_import_source(self):
        from libcellml import Error, ImportSource

        # ImportSourcePtr getImportSource()
        e = Error()
        self.assertIsNone(e.getComponent())
        name = 'uri'
        i = ImportSource()
        i.setId(name)
        e.setImportSource(i)
        self.assertIsInstance(e.getImportSource(), ImportSource)
        self.assertEqual(e.getImportSource().getId(), name)
Esempio n. 3
0
    def test_item(self):
        from libcellml import Component, Issue, ImportSource, Model, Unit
        from libcellml import Reset, Units, Variable, CellmlElementType, VariablePair

        i = Issue()

        item = i.item()
        self.assertEqual(CellmlElementType.UNDEFINED, item[0])
        self.assertIsNone(item[1])

        i.setItem(CellmlElementType.VARIABLE, Variable("v"))
        vItem = i.item()
        self.assertEqual(CellmlElementType.VARIABLE, vItem[0])
        self.assertEqual("v", vItem[1].name())

        i.setItem(CellmlElementType.UNITS, Units("u"))
        uItem = i.item()
        self.assertEqual(CellmlElementType.UNITS, uItem[0])
        self.assertEqual("u", uItem[1].name())

        u = Units("ui")
        u.addUnit("volt")
        u.addUnit("second")
        u.addUnit("metre")
        i.setItem(CellmlElementType.UNIT, Unit(u, 2))
        uiItem = i.item()
        self.assertEqual(CellmlElementType.UNIT, uiItem[0])
        self.assertEqual("ui", uiItem[1].units().name())
        self.assertEqual(2, uiItem[1].index())

        v1 = Variable("v1")
        v2 = Variable("v2")
        i.setItem(CellmlElementType.CONNECTION, VariablePair(v1, v2))
        vpItem = i.item()
        self.assertEqual(CellmlElementType.CONNECTION, vpItem[0])
        self.assertEqual("v1", vpItem[1].variable1().name())
        self.assertEqual("v2", vpItem[1].variable2().name())

        v3 = Variable("v3")
        v4 = Variable("v4")
        i.setItem(CellmlElementType.MAP_VARIABLES, VariablePair(v3, v4))
        vpItem = i.item()
        self.assertEqual(CellmlElementType.MAP_VARIABLES, vpItem[0])
        self.assertEqual("v3", vpItem[1].variable1().name())
        self.assertEqual("v4", vpItem[1].variable2().name())

        r = Reset()
        r.setId("r")
        i.setItem(CellmlElementType.RESET, r)
        rItem = i.item()
        self.assertEqual(CellmlElementType.RESET, rItem[0])
        self.assertEqual("r", rItem[1].id())

        r.setId("r1")
        i.setItem(CellmlElementType.RESET_VALUE, r)
        rItem = i.item()
        self.assertEqual(CellmlElementType.RESET_VALUE, rItem[0])
        self.assertEqual("r1", rItem[1].id())

        r.setId("r2")
        i.setItem(CellmlElementType.TEST_VALUE, r)
        rItem = i.item()
        self.assertEqual(CellmlElementType.TEST_VALUE, rItem[0])
        self.assertEqual("r2", rItem[1].id())

        i.setItem(CellmlElementType.MODEL, Model("m"))
        mItem = i.item()
        self.assertEqual(CellmlElementType.MODEL, mItem[0])
        self.assertEqual("m", mItem[1].name())

        i.setItem(CellmlElementType.ENCAPSULATION, Model("e"))
        mItem = i.item()
        self.assertEqual(CellmlElementType.ENCAPSULATION, mItem[0])
        self.assertEqual("e", mItem[1].name())

        iS  = ImportSource()
        iS.setId("is")
        i.setItem(CellmlElementType.IMPORT, iS)
        isItem = i.item()
        self.assertEqual(CellmlElementType.IMPORT, isItem[0])
        self.assertEqual("is", isItem[1].id())

        i.setItem(CellmlElementType.COMPONENT, Component("c"))
        cItem = i.item()
        self.assertEqual(CellmlElementType.COMPONENT, cItem[0])
        self.assertEqual("c", cItem[1].name())

        i.setItem(CellmlElementType.COMPONENT_REF, Component("c1"))
        cItem = i.item()
        self.assertEqual(CellmlElementType.COMPONENT_REF, cItem[0])
        self.assertEqual("c1", cItem[1].name())