def test_invalid_command(self):
        """Test case for validating that when we train a model and add it to task queue that it will run."""
        mgr = DetectorPipeline()

        class mock_func:
            def execute(self):
                print("Test")

        mock = mock_func()
        with self.assertRaises(TypeError) as context:
            mgr.add_steps(mock)
        mgr.clear()
    def test_valid_command(self):
        """Test case for validating that when we train a model and add it to task queue that it will run."""
        mgr = DetectorPipeline()

        class mock_func(AbstractCommand):
            def execute(self):
                print("Test")

        mock = mock_func()
        mgr.add_steps(mock)
        self.assertEqual(len(mgr), TASKS_IN_QUEUE)
        self.assertNotEqual(mgr.count, TASKS_IN_QUEUE)
        mgr.execute_steps()
        self.assertEqual(mgr.count, TASKS_IN_QUEUE)
        mgr.clear()
    def test_train_command(self):
        """Test case for validating that when we train a model and add it to task queue that it will run."""
        mgr = DetectorPipeline()
        config = Configuration()
        config.STORAGE_DATASOURCE = "local"
        config.STORAGE_DATASINK = "stdout"
        config.LS_INPUT_PATH = "validation_data/Hadoop_2k.json"
        storage_adapter = SomStorageAdapter(config=config, feedback_strategy=None)
        model_adapter = SomModelAdapter(storage_adapter)
        tc = SomTrainJob(node_map=2, model_adapter=model_adapter)

        mgr.add_steps(tc)
        self.assertEqual(len(mgr), TASKS_IN_QUEUE)
        self.assertNotEqual(mgr.count, TASKS_IN_QUEUE)
        mgr.execute_steps()
        self.assertEqual(mgr.count, TASKS_IN_QUEUE)
        mgr.clear()
def pipeline():
    """Providing pipeline that clears up history of task runs."""
    pipeline = DetectorPipeline()
    yield pipeline
    pipeline.clear()