Пример #1
0
    def test_remove_model_method(self):
        """Testing the remove_model() method."""
        # arrange
        # instantiating the model manager class
        model_manager = ModelManager()

        # adding the model
        model_manager.load_model("tests.mocks.MLModelMock")

        # act
        exception_raised1 = False
        # accessing the MLModelMock model object
        try:
            model_manager.remove_model(qualified_name="qualified_name")
        except Exception as e:
            exception_raised1 = True

        exception_raised2 = False
        exception_message2 = ""
        # trying to access the model that was removed
        try:
            model = model_manager.get_model(qualified_name="qualified_name")
        except Exception as e:
            exception_raised2 = True
            exception_message2 = str(e)

        # assert
        self.assertFalse(exception_raised1)
        self.assertTrue(exception_raised2)
        self.assertTrue(
            exception_message2 ==
            "Instance of model 'qualified_name' not found in ModelManager.")
Пример #2
0
    def test_remove_model_method_with_missing_model(self):
        """Testing that the ModelManager raises ValueError exception when removing a model that is not found."""
        # arrange
        model_manager = ModelManager()

        model_manager.load_model("tests.mocks.MLModelMock")

        # act
        exception_raised = False
        exception_message = ""
        try:
            model_manager.remove_model(qualified_name="asdf")
        except Exception as e:
            exception_raised = True
            exception_message = str(e)

        # assert
        self.assertTrue(exception_raised)
        self.assertTrue(exception_message ==
                        "Instance of model 'asdf' not found in ModelManager.")