Exemplo n.º 1
0
 def test_ucvm_get_model_instance(self):
     """
     Tests that UCVM can retrieve a model instance correctly. Also tests to ensure that providing a bad model to
     this raises the correct error.
     """
     self.assertEqual(UCVM.get_model_instance("1d").get_metadata()["id"], "1d")
     stdout = sys.stdout
     sys.stdout = None
     with self.assertRaises(UCVMError):
         UCVM.get_model_instance("bob")
     sys.stdout = stdout
Exemplo n.º 2
0
    def test_ucvm_load_models(self):
        """
        Test that UCVM can load all the installed models without error.
        """
        installed_models = UCVM.get_list_of_installed_models()

        for key in installed_models:
            for model in installed_models[key]:
                m_py = UCVM.get_model_instance(model["id"])
                self.assertEqual(m_py.get_metadata()["name"], model["name"])
                self.assertEqual(UCVM.instantiated_models[model["id"]].get_metadata()["name"],
                                 model["name"])
Exemplo n.º 3
0
    def _add_corner_and_depth_information():
        target.corners = {
            "bl": {
                "e": None,
                "n": None
            },
            "tr": {
                "e": None,
                "n": None
            }
        }

        target.max_depth = 0

        for _, model_dict in UCVM.parse_model_string(name).items():
            for _, model in model_dict.items():
                model_cpy = model.split(";")[0]
                if UCVM.get_model_type(model_cpy) == "velocity":
                    coverage = UCVM.get_model_instance(
                        model_cpy).get_metadata()["coverage"]
                    if "depth" in coverage and float(
                            coverage["depth"]) > target.max_depth:
                        target.max_depth = float(coverage["depth"])
                    elif "depth" not in coverage and 50000 < target.max_depth:
                        target.max_depth = 50000

                    if coverage["bottom_left"]["e"] is not None and \
                            (target.corners["bl"]["e"] is None or
                             float(coverage["bottom_left"]["e"]) < target.corners["bl"]["e"]):
                        target.corners["bl"]["e"] = float(
                            coverage["bottom_left"]["e"])
                    if coverage["bottom_left"]["n"] is not None and \
                            (target.corners["bl"]["n"] is None or
                             float(coverage["bottom_left"]["n"]) < target.corners["bl"]["n"]):
                        target.corners["bl"]["n"] = float(
                            coverage["bottom_left"]["n"])
                    if coverage["top_right"]["e"] is not None and \
                            (target.corners["tr"]["e"] is None or
                             float(coverage["top_right"]["e"]) > target.corners["tr"]["e"]):
                        target.corners["tr"]["e"] = float(
                            coverage["top_right"]["e"])
                    if coverage["top_right"]["n"] is not None and \
                            (target.corners["tr"]["n"] is None or
                             float(coverage["top_right"]["n"]) > target.corners["tr"]["n"]):
                        target.corners["tr"]["n"] = float(
                            coverage["top_right"]["n"])
                    break

        if target.max_depth == 0:
            target.max_depth = 50000
Exemplo n.º 4
0
    def _add_corner_and_depth_information():
        target.corners = {
            "bl": {
                "e": None,
                "n": None
            },
            "tr": {
                "e": None,
                "n": None
            }
        }

        target.max_depth = 0

        for _, model_dict in UCVM.parse_model_string(name).items():
            for _, model in model_dict.items():
                model_cpy = model.split(";")[0]
                if UCVM.get_model_type(model_cpy) == "velocity":
                    coverage = UCVM.get_model_instance(model_cpy).get_metadata()["coverage"]
                    if "depth" in coverage and float(coverage["depth"]) > target.max_depth:
                        target.max_depth = float(coverage["depth"])
                    elif "depth" not in coverage and 50000 < target.max_depth:
                        target.max_depth = 50000

                    if coverage["bottom_left"]["e"] is not None and \
                            (target.corners["bl"]["e"] is None or
                             float(coverage["bottom_left"]["e"]) < target.corners["bl"]["e"]):
                        target.corners["bl"]["e"] = float(coverage["bottom_left"]["e"])
                    if coverage["bottom_left"]["n"] is not None and \
                            (target.corners["bl"]["n"] is None or
                             float(coverage["bottom_left"]["n"]) < target.corners["bl"]["n"]):
                        target.corners["bl"]["n"] = float(coverage["bottom_left"]["n"])
                    if coverage["top_right"]["e"] is not None and \
                            (target.corners["tr"]["e"] is None or
                             float(coverage["top_right"]["e"]) > target.corners["tr"]["e"]):
                        target.corners["tr"]["e"] = float(coverage["top_right"]["e"])
                    if coverage["top_right"]["n"] is not None and \
                            (target.corners["tr"]["n"] is None or
                             float(coverage["top_right"]["n"]) > target.corners["tr"]["n"]):
                        target.corners["tr"]["n"] = float(coverage["top_right"]["n"])
                    break

        if target.max_depth == 0:
            target.max_depth = 50000
Exemplo n.º 5
0
def make_suite() -> unittest.TestSuite:
    suite = unittest.TestSuite()

    models = UCVM.get_list_of_installed_models()

    for key in models:
        for model in models[key]:
            path = os.path.join(UCVM.get_model_instance(model["id"]).model_location, "test_" +
                                model["id"] + ".py")
            if os.path.exists(path):
                new_class = __import__("ucvm.models." + model["id"] + ".test_" + model["id"],
                                       fromlist=model["class"] + "Test")
                suite.addTest(
                    unittest.makeSuite(getattr(new_class, model["class"] + "Test"), "test_")
                )
            if key == "velocity":
                add_acceptance_test_methods(UCVMModelAcceptanceTest, model["id"])

    suite.addTest(unittest.makeSuite(UCVMModelAcceptanceTest, "test_"))

    return suite
Exemplo n.º 6
0
def make_suite() -> unittest.TestSuite:
    suite = unittest.TestSuite()

    models = UCVM.get_list_of_installed_models()

    for key in models:
        for model in models[key]:
            path = os.path.join(
                UCVM.get_model_instance(model["id"]).model_location,
                "test_" + model["id"] + ".py")
            if os.path.exists(path):
                new_class = __import__("ucvm.models." + model["id"] +
                                       ".test_" + model["id"],
                                       fromlist=model["class"] + "Test")
                suite.addTest(
                    unittest.makeSuite(
                        getattr(new_class, model["class"] + "Test"), "test_"))
            if key == "velocity":
                add_acceptance_test_methods(UCVMModelAcceptanceTest,
                                            model["id"])

    suite.addTest(unittest.makeSuite(UCVMModelAcceptanceTest, "test_"))

    return suite