Beispiel #1
0
    def test_is_kind(self):
        from libcellml import Error

        # bool isKind(const Kind &kind)
        e = Error()
        self.assertTrue(e.isKind(Error.Kind.UNDEFINED))
        self.assertFalse(e.isKind(Error.Kind.MODEL))
Beispiel #2
0
    def test_create_destroy(self):
        from libcellml import Error

        x = Error()
        del (x)
        y = Error()
        z = Error(y)
        del (y, z)
Beispiel #3
0
    def test_error_count(self):
        from libcellml import Logger, Error

        # size_t errorCount()
        x = Logger()
        self.assertEqual(x.errorCount(), 0)
        x.addError(Error())
        self.assertEqual(x.errorCount(), 1)
        x.addError(Error())
        self.assertEqual(x.errorCount(), 2)
Beispiel #4
0
    def test_clear_errors(self):
        from libcellml import Logger, Error

        # void clearErrors()
        x = Logger()
        self.assertEqual(x.errorCount(), 0)
        x.addError(Error())
        x.addError(Error())
        self.assertEqual(x.errorCount(), 2)
        x.clearErrors()
        self.assertEqual(x.errorCount(), 0)
Beispiel #5
0
    def test_get_error(self):
        from libcellml import Logger, Error

        # ErrorPtr getError(size_t index)
        x = Logger()
        self.assertIsNone(x.getError(0))
        self.assertIsNone(x.getError(1))
        self.assertIsNone(x.getError(-1))
        e = Error()
        e.setKind(Error.Kind.MODEL)
        x.addError(e)
        self.assertIsNotNone(x.getError(0))
        self.assertIsNone(x.getError(1))
        self.assertEqual(x.getError(0).getKind(), Error.Kind.MODEL)
Beispiel #6
0
    def test_kind_enum(self):
        from libcellml import Error

        self.assertIsInstance(Error.Kind.COMPONENT, int)
        self.assertIsInstance(Error.Kind.CONNECTION, int)
        self.assertIsInstance(Error.Kind.ENCAPSULATION, int)
        self.assertIsInstance(Error.Kind.IMPORT, int)
        self.assertIsInstance(Error.Kind.MATHML, int)
        self.assertIsInstance(Error.Kind.MODEL, int)
        self.assertIsInstance(Error.Kind.UNDEFINED, int)
        self.assertIsInstance(Error.Kind.UNITS, int)
        self.assertIsInstance(Error.Kind.VARIABLE, int)
        self.assertIsInstance(Error.Kind.XML, int)

        # Test conversion to enum
        e = Error()
        e.setKind(Error.Kind.COMPONENT)
        self.assertRaises(RuntimeError, e.setKind, Error.Kind.COMPONENT - 1)
        self.assertRaises(RuntimeError, e.setKind, Error.Kind.XML + 1)
Beispiel #7
0
    def test_set_description(self):
        from libcellml import Error

        # void setDescription(const std::string &description)
        e = Error()
        e.setDescription('hello')
        e.setDescription('')
Beispiel #8
0
    def test_get_kind(self):
        from libcellml import Error

        # Kind getKind()
        e = Error()
        self.assertEqual(e.getKind(), Error.Kind.UNDEFINED)
        e.setKind(Error.Kind.MATHML)
        self.assertEqual(e.getKind(), Error.Kind.MATHML)
Beispiel #9
0
    def test_get_component(self):
        from libcellml import Error, Component

        # ComponentPtr getComponent()
        e = Error()
        self.assertIsNone(e.getComponent())
        name = 'cellml'
        c = Component()
        c.setName(name)
        e.setComponent(c)
        self.assertIsInstance(e.getComponent(), Component)
        self.assertEqual(e.getComponent().getName(), name)
Beispiel #10
0
    def test_get_model(self):
        from libcellml import Error, Model

        # ModelPtr getModel()
        e = Error()
        self.assertIsNone(e.getModel())
        name = 'moodle'
        m = Model()
        m.setName(name)
        e.setModel(m)
        self.assertIsInstance(e.getModel(), Model)
        self.assertEqual(e.getModel().getName(), name)
Beispiel #11
0
    def test_get_when(self):
        from libcellml import Error, When

        # WhenPtr getWhen() const;
        e = Error()
        self.assertIsNone(e.getWhen())
        name = 'var'
        w = When()
        w.setId(name)
        e.setWhen(w)
        self.assertIsInstance(e.getWhen(), When)
        self.assertEqual(e.getWhen().getId(), name)
Beispiel #12
0
    def test_get_reset(self):
        from libcellml import Error, Reset

        # ResetPtr getReset() const;
        e = Error()
        self.assertIsNone(e.getReset())
        name = 'res'
        r = Reset()
        r.setId(name)
        e.setReset(r)
        self.assertIsInstance(e.getReset(), Reset)
        self.assertEqual(e.getReset().getId(), name)
Beispiel #13
0
    def test_get_variable(self):
        from libcellml import Error, Variable

        # VariablePtr getVariable()
        e = Error()
        self.assertIsNone(e.getVariable())
        name = 'var'
        v = Variable()
        v.setName(name)
        e.setVariable(v)
        self.assertIsInstance(e.getVariable(), Variable)
        self.assertEqual(e.getVariable().getName(), name)
Beispiel #14
0
    def test_get_units(self):
        from libcellml import Error, Units

        # UnitsPtr getUnits()
        e = Error()
        self.assertIsNone(e.getUnits())
        name = 'furlong'
        u = Units()
        u.setName(name)
        e.setUnits(u)
        self.assertIsInstance(e.getUnits(), Units)
        self.assertEqual(e.getUnits().getName(), name)
Beispiel #15
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)
Beispiel #16
0
    def test_get_description(self):
        from libcellml import Error

        # std::string getDescription()
        d = 'hi'
        e = Error()
        self.assertEqual(e.getDescription(), '')
        e.setDescription(d)
        self.assertEqual(e.getDescription(), d)
        del (d, e)
Beispiel #17
0
    def test_set_units(self):
        from libcellml import Error, Units

        # void setUnits(const UnitsPtr &units)
        e = Error()
        e.setUnits(Units())
Beispiel #18
0
    def test_set_when(self):
        from libcellml import Error, When

        # void setWhen(const WhenPtr &when);
        e = Error()
        e.setWhen(When())
Beispiel #19
0
    def test_set_reset(self):
        from libcellml import Error, Reset

        # void setReset(const ResetPtr &reset);
        e = Error()
        e.setReset(Reset())
Beispiel #20
0
    def test_set_variable(self):
        from libcellml import Error, Variable

        # void setVariable(const VariablePtr &variable)
        e = Error()
        e.setVariable(Variable())
Beispiel #21
0
    def test_set_rule(self):
        from libcellml import Error, SpecificationRule

        # void setRule(SpecificationRule rule)
        e = Error()
        e.setRule(SpecificationRule.MAP_VARIABLES_VARIABLE2)
Beispiel #22
0
    def test_specification_rule_enum(self):
        from libcellml import Error, SpecificationRule

        self.assertIsInstance(SpecificationRule.UNDEFINED, int)
        self.assertIsInstance(SpecificationRule.DATA_REPR_IDENTIFIER_UNICODE,
                              int)
        self.assertIsInstance(
            SpecificationRule.DATA_REPR_IDENTIFIER_LATIN_ALPHANUM, int)
        self.assertIsInstance(
            SpecificationRule.DATA_REPR_IDENTIFIER_AT_LEAST_ONE_ALPHANUM, int)
        self.assertIsInstance(
            SpecificationRule.DATA_REPR_IDENTIFIER_BEGIN_EURO_NUM, int)
        self.assertIsInstance(SpecificationRule.DATA_REPR_IDENTIFIER_IDENTICAL,
                              int)
        self.assertIsInstance(SpecificationRule.DATA_REPR_NNEG_INT_BASE10, int)
        self.assertIsInstance(SpecificationRule.DATA_REPR_NNEG_INT_EURO_NUM,
                              int)
        self.assertIsInstance(SpecificationRule.MODEL_ELEMENT, int)
        self.assertIsInstance(SpecificationRule.MODEL_NAME, int)
        self.assertIsInstance(SpecificationRule.MODEL_CHILD, int)
        self.assertIsInstance(
            SpecificationRule.MODEL_MORE_THAN_ONE_ENCAPSULATION, int)
        self.assertIsInstance(SpecificationRule.IMPORT_HREF, int)
        self.assertIsInstance(SpecificationRule.IMPORT_CHILD, int)
        self.assertIsInstance(SpecificationRule.IMPORT_CIRCULAR, int)
        self.assertIsInstance(SpecificationRule.IMPORT_UNITS_NAME, int)
        self.assertIsInstance(SpecificationRule.IMPORT_UNITS_REF, int)
        self.assertIsInstance(SpecificationRule.IMPORT_COMPONENT_NAME, int)
        self.assertIsInstance(SpecificationRule.IMPORT_COMPONENT_REF, int)
        self.assertIsInstance(SpecificationRule.UNITS_NAME, int)
        self.assertIsInstance(SpecificationRule.UNITS_NAME_UNIQUE, int)
        self.assertIsInstance(SpecificationRule.UNITS_STANDARD, int)
        self.assertIsInstance(SpecificationRule.UNITS_CHILD, int)
        self.assertIsInstance(SpecificationRule.UNIT_UNITS_REF, int)
        self.assertIsInstance(SpecificationRule.UNIT_DIGRAPH, int)
        self.assertIsInstance(SpecificationRule.UNIT_CIRCULAR_REF, int)
        self.assertIsInstance(SpecificationRule.UNIT_OPTIONAL_ATTRIBUTE, int)
        self.assertIsInstance(SpecificationRule.UNIT_PREFIX, int)
        self.assertIsInstance(SpecificationRule.UNIT_MULTIPLIER, int)
        self.assertIsInstance(SpecificationRule.UNIT_EXPONENT, int)
        self.assertIsInstance(SpecificationRule.COMPONENT_NAME, int)
        self.assertIsInstance(SpecificationRule.COMPONENT_CHILD, int)
        self.assertIsInstance(SpecificationRule.VARIABLE_NAME, int)
        self.assertIsInstance(SpecificationRule.VARIABLE_UNITS, int)
        self.assertIsInstance(SpecificationRule.VARIABLE_INTERFACE, int)
        self.assertIsInstance(SpecificationRule.VARIABLE_INITIAL_VALUE, int)
        self.assertIsInstance(SpecificationRule.RESET_VARIABLE_REFERENCE, int)
        self.assertIsInstance(SpecificationRule.RESET_ORDER, int)
        self.assertIsInstance(SpecificationRule.RESET_CHILD, int)
        self.assertIsInstance(SpecificationRule.WHEN_ORDER, int)
        self.assertIsInstance(SpecificationRule.WHEN_CHILD, int)
        self.assertIsInstance(SpecificationRule.MATH_MATHML, int)
        self.assertIsInstance(SpecificationRule.MATH_CHILD, int)
        self.assertIsInstance(SpecificationRule.MATH_CI_VARIABLE_REFERENCE,
                              int)
        self.assertIsInstance(SpecificationRule.MATH_CN_UNITS_ATTRIBUTE, int)
        self.assertIsInstance(SpecificationRule.ENCAPSULATION_COMPONENT_REF,
                              int)
        self.assertIsInstance(
            SpecificationRule.COMPONENT_REF_COMPONENT_ATTRIBUTE, int)
        self.assertIsInstance(SpecificationRule.COMPONENT_REF_CHILD, int)
        self.assertIsInstance(SpecificationRule.COMPONENT_REF_ENCAPSULATION,
                              int)
        self.assertIsInstance(SpecificationRule.CONNECTION_COMPONENT1, int)
        self.assertIsInstance(SpecificationRule.CONNECTION_COMPONENT2, int)
        self.assertIsInstance(SpecificationRule.CONNECTION_UNIQUE_TRANSITIVE,
                              int)
        self.assertIsInstance(SpecificationRule.CONNECTION_MAP_VARIABLES, int)
        self.assertIsInstance(SpecificationRule.MAP_VARIABLES_VARIABLE1, int)
        self.assertIsInstance(SpecificationRule.MAP_VARIABLES_VARIABLE2, int)
        self.assertIsInstance(SpecificationRule.MAP_VARIABLES_UNIQUE, int)

        # Test conversion to enum
        e = Error()
        e.setRule(SpecificationRule.UNDEFINED)
        self.assertRaises(RuntimeError, e.setRule,
                          SpecificationRule.UNDEFINED - 1)
        self.assertRaises(RuntimeError, e.setRule,
                          SpecificationRule.MAP_VARIABLES_UNIQUE + 1)
        del (e)
Beispiel #23
0
    def test_set_model(self):
        from libcellml import Error, Model

        # void setModel(const ModelPtr &model)
        e = Error()
        e.setModel(Model())
Beispiel #24
0
    def test_set_import_source(self):
        from libcellml import Error, ImportSource

        # void setImportSource(const ImportSourcePtr &import)
        e = Error()
        e.setImportSource(ImportSource())
Beispiel #25
0
    def test_set_component(self):
        from libcellml import Error, Component

        # void setComponent(const ComponentPtr &component)
        e = Error()
        e.setComponent(Component())
Beispiel #26
0
    def test_get_specification_heading(self):
        from libcellml import Error

        # std::string getSpecificationHeading()
        e = Error()
        self.assertEqual('', e.getSpecificationHeading())
Beispiel #27
0
    def test_get_rule(self):
        from libcellml import Error, SpecificationRule

        # SpecificationRule getRule()
        e = Error()
        self.assertEqual(e.getRule(), SpecificationRule.UNDEFINED)
Beispiel #28
0
    def test_add_error(self):
        from libcellml import Logger, Error

        # void addError(const ErrorPtr error)
        x = Logger()
        x.addError(Error())
Beispiel #29
0
    def test_set_kind(self):
        from libcellml import Error

        # void setKind(Kind kind)
        e = Error()
        e.setKind(Error.Kind.CONNECTION)