예제 #1
0
 def test_validateHTMLInPackage(self):
     import buildingspy.development.validator as v
     val = v.Validator()
     myMoLib = os.path.join("buildingspy", "tests", "MyModelicaLibrary")
     # Get a list whose elements are the error strings
     errStr = val.validateHTMLInPackage(myMoLib)
     self.assertEqual(len(errStr), 0)
     # Test a package that does not exist
     self.assertRaises(ValueError, val.validateHTMLInPackage, "non_existent_modelica_package")
예제 #2
0
def validate():
    import buildingspy.io.reporter as rep
    import buildingspy.development.validator as v
    val = v.Validator()
    errMsg = val.validateHTMLInPackage(".")
    for i in range(len(errMsg)):
        if i == 0:
            print "The following malformed html syntax has been found:\n%s" % errMsg[i]
        else:
            print errMsg[i]
예제 #3
0
def _validate_html(path):  # validate the html syntax
    import buildingspy.development.validator as v
    val = v.Validator()
    errMsg = val.validateHTMLInPackage(path)
    n_msg = len(errMsg)
    for i in range(n_msg):
        if i == 0:
            print("The following malformed html syntax has been found:\n%s" %
                  errMsg[i])
        else:
            print(errMsg[i])
    if n_msg == 0:
        return 0
    else:
        return 1
예제 #4
0
def _validate_html(path):
    import buildingspy.development.validator as v

    val = v.Validator()
    errMsg = val.validateHTMLInPackage(path)
    n_msg = len(errMsg)
    for i in range(n_msg):
        if i == 0:
            print "The following malformed html syntax has been found:\n%s" % errMsg[
                i].encode('utf-8')
        else:
            print errMsg[i].encode('utf-8')

    print "Number of total conflicting files: ", n_msg

    if n_msg == 0:
        return 0
    else:
        return 1
예제 #5
0
def _validate_experiment_setup(path):
    import buildingspy.development.validator as v

    val = v.Validator()
    retVal = val.validateExperimentSetup(path)
예제 #6
0
def _validate_experiment_setup(path):  # validate regression test setup
    import buildingspy.development.validator as v
    val = v.Validator()
    retVal = val.validateExperimentSetup(path)
    return retVal
예제 #7
0
def _validate_experiment_setup(path):
    import buildingspy.development.validator as v

    val = v.Validator()
    # This throws a ValueError exception if the experiment setup is incorrect
    val.validateExperimentSetup(path)
예제 #8
0
    def test_validateExperimentSetup(self):

        import buildingspy.development.validator as v
        val = v.Validator()
        myMoLib = os.path.join("buildingspy", "tests", "MyModelicaLibrary")

        #########################################
        # Checking default library
        val.validateExperimentSetup(myMoLib)

        #########################################
        # Checking missing experiment
        self.run_case(val, myMoLib, "Test1", "", "tolerance=1e-6,",
                      "without experiment annotation.")

        ###########################################
        # Checking missing tolerance in mos file
        self.run_case(val, myMoLib, "Test2", "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "", "A minimum tolerance of 1e-6 is required for OPTIMICA and JModelica.")

        ###########################################
        # Checking missing tolerance in mo file
        self.run_case(val, myMoLib, "Test3", "experiment(StopTime=1.0),", "stopTime=1.0,",
                      "A minimum tolerance of 1e-6 is required for OPTIMICA and JModelica.")

        ###########################################
        # Checking tolerances mismatch
        self.run_case(val, myMoLib, "Test4", "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "tolerance=1e-3, stopTime=1.0,",
                      "The tolerance found is bigger than 1e-6")

        #########################################
        # Checking tolerances mismatch
        self.run_case(val, myMoLib, "Test5", "experiment(Tolerance=1e-3, StopTime=1.0),",
                      "tolerance=1e-6, stopTime=1.0,",
                      "different from the (default) value=1e-6")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "Test6", "experiment(Tolerance=1e-6, StopTime=2.0),",
                      "tolerance=1e-6,",
                      "The value of StopTime=2.0 is different from the (default) value=1.0")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "Test7", "experiment(Tolerance=1e-6, StopTime=30.0),",
                      "tolerance=1e-6, stopTime=15,",
                      "The value of StopTime=30.0 is different from the")

        ###########################################
        # Checking wrong literal in StopTime
        self.run_case(val, myMoLib, "Test8", "experiment(Tolerance=1e-6, StopTime=2*5),",
                      "tolerance=1e-6, stopTime=10,",
                      "contains invalid expressions such as")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(
            val,
            myMoLib,
            "Test9",
            "experiment(Tolerance=1e-6, StartTime=2, StopTime=1.0),",
            "tolerance=1e-6, stopTime=1.0,",
            "The value of StartTime=2 is different from the (default) value=0.0")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "Test10", "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "tolerance=1e-6, startTime=2.0, stopTime=1.0,",
                      "The parameter name startTime is defined in the mos file")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(
            val,
            myMoLib,
            "Test11",
            "experiment(Tolerance=1e-6, StartTime=15, StopTime=1.0),",
            "tolerance=1e-6, startTime=10, stopTime=1.0,",
            "The value of StartTime=15 is different from the")

        ###########################################
        # Checking missing StopTime in mo mismatch
        self.run_case(val, myMoLib, "Test12", "experiment(Tolerance=1e-6),",
                      "tolerance=1e-6,",
                      "without StopTime in experiment annotation")

        ###########################################
        # Checking wrong data type that can cause an overflow
        # In JModelica's CI testing, the maximum integer is 2147483647
        self.run_case(
            val,
            myMoLib,
            "Test13",
            "experiment(Tolerance=1e-6, StartTime=0, StopTime=2147483648),",
            "tolerance=1e-6, startTime=0, stopTime=2147483648,",
            "Integer overflow: Integers can be -2147483648 to 2147483647, received")
        self.run_case(
            val,
            myMoLib,
            "Test14",
            "experiment(Tolerance=1e-6, StartTime=-2147483649, StopTime=0),",
            "tolerance=1e-6, startTime=-2147483649, stopTime=0,",
            "Integer overflow: Integers can be -2147483648 to 2147483647, received")
예제 #9
0
    def test_validateExperimentSetup(self):

        import buildingspy.development.validator as v
        val = v.Validator()
        myMoLib = os.path.join("buildingspy", "tests", "MyModelicaLibrary")

        #########################################
        # Checking default library
        val.validateExperimentSetup(myMoLib)

        #########################################
        # Checking missing experiment
        self.run_case(val, myMoLib, "", "tolerance=1e-6,",
                      "without experiment annotation.")

        ###########################################
        # Checking missing tolerance in mos file
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "", "A maximum tolerance of 1e-6 is required")

        ###########################################
        # Checking missing tolerance in mo file
        self.run_case(val, myMoLib, "experiment(StopTime=1.0),",
                      "stopTime=1.0,", "A maximum tolerance of 1e-6 is required by JModelica.")

        ###########################################
        # Checking tolerances mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "tolerance=1e-3, stopTime=1.0,",
                      "The tolerance found is bigger than 1e-6")

        #########################################
        # Checking tolerances mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-3, StopTime=1.0),",
                      "tolerance=1e-6, stopTime=1.0,",
                      "different from the (default) value=1e-6")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=2.0),",
                      "tolerance=1e-6,",
                      "The value of StopTime=2.0 is different from the (default) value=1.0")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=30.0),",
                      "tolerance=1e-6, stopTime=15,",
                      "The value of StopTime=30.0 is different from the")
#
        ###########################################
        # Checking wrong literal in StopTime
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=2*5),",
                      "tolerance=1e-6, stopTime=10,",
                      "contains invalid expressions such as")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StartTime=2, StopTime=1.0),",
                      "tolerance=1e-6, stopTime=1.0,",
                      "The value of StartTime=2 is different from the (default) value=0.0")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StopTime=1.0),",
                      "tolerance=1e-6, startTime=2.0, stopTime=1.0,",
                      "The parameter name startTime is defined in the mos file")

        ###########################################
        # Checking stopTime mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6, StartTime=15, StopTime=1.0),",
                      "tolerance=1e-6, startTime=10, stopTime=1.0,",
                      "The value of StartTime=15 is different from the")

        ###########################################
        # Checking missing StopTime in mo mismatch
        self.run_case(val, myMoLib, "experiment(Tolerance=1e-6),",
                      "tolerance=1e-6,",
                      "without StopTime in experiment annotation")