Exemple #1
0
    def test_has_unresolved_imports(self):
        from libcellml import Model, Component, ImportSource

        # bool hasUnresolvedImports();
        m = Model()
        self.assertFalse(m.hasUnresolvedImports())
        c = Component()
        m.addComponent(c)
        self.assertFalse(m.hasUnresolvedImports())
        c.setImportSource(ImportSource())
        self.assertTrue(m.hasUnresolvedImports())
    #      the n_gate_equations component. 
    imported_gate = Component('importedGate')
    n_gate_equations.addComponent(imported_gate)

    #  4.c 
    #      Set the import reference on the component you just created to be the name
    #      of the component in the GateModel.cellml file that you want to use.  In this
    #      example, it is 'gateEquations'.
    imported_gate.setImportReference('gateEquations')

    #  4.d 
    #      Associate the import source with the component using the setImportSource function.
    #      Note that this step also makes the import source available to other items through the 
    #      Model.importSource(index) function.  This way the same model file can be used as a 
    #      source for more than one item.
    imported_gate.setImportSource(gate_import_source)

    #  4.e 
    #      Validate the model and confirm that there are no issues.
    validator.validateModel(model)
    print_issues(validator)

    #  end 4

    print('------------------------------------------------------------')
    print('   STEP 5: Specify imports for the controller component     ')
    print('------------------------------------------------------------')

    #  STEP 5: Repeat Step 4 to import a controller component.  This should be 
    #          at the top of the encapsulation hierarchy, and should import the component
    #          named 'controller' from the file 'PotassiumChannelController.cellml'.