Exemplo n.º 1
0
    def __init__(self, argv=None):
        self.argv = argv
        self.pipeline_executors = []
        if len(argv) > 1:
            self.config_dir = argv[1]
            self._config_ctx = MainConfigContext.get_instance(self.config_dir)
            self.init_workspace(in_place=False)
            self._config_ctx.search_config(self.config_dir)
        else:
            self._config_ctx = MainConfigContext.get_instance()
            is_path_found = self._config_ctx.scan_paths()
            if is_path_found:
                self.init_workspace(True)
            else:
                raise RunnerException("Configuration directory not specified.\n"
                                      "Please indicate path where EaseCI will create workspace for config, projects etc.\n"
                                      "Run application with argument $python3 ease_ci_app.py "
                                      "'/absolute/path/on/machine'\n\n"
                                      "Be advised that if configuration exists Ease will looking for general.yml file "
                                      "for bootstrapping instance")

        if EaseRunner.__instance is not None:
            raise RunnerException('Cannot instantiate EaseRunner twice!')
        else:
            EaseRunner.__instance = self
Exemplo n.º 2
0
    def test_should_initialize_object_with_parameters_from_general_yml_file(
            self):
        path = str(pwd()) + '/app/tests/lib/config/config'
        EaseRunner.get_instance(['', path])
        MainConfigContext.get_instance()
        publisher = OutputPublisher()
        info = publisher.info()

        self.assertEqual(100, info['max_queue_size'])
        self.assertEqual(15, info['max_consumers_size'])
        self.assertFalse(info['autopublishing'])
Exemplo n.º 3
0
    def test_should_get_property_returns_value_with_success_when_initialize_MainConfigContext_with_no_specified_path(
            self):
        config = MainConfigContext.get_instance()
        config.scan_paths()
        result = config.get_property('main.paths.temp')

        self.assertIsNotNone(result)
        self.assertEqual(result, '/tmp/ease')
Exemplo n.º 4
0
    def test_config_context_should_initialize_with_path_provided_as_argument(
            self):
        config = MainConfigContext.get_instance(self._dir)
        result = config.scan_paths()
        prop = config.get_property('main.paths.temp')

        self.assertIsNotNone(config)
        self.assertIsNotNone(prop)
        self.assertTrue(result)
        self.assertEqual('/tmp/ease', prop)
Exemplo n.º 5
0
 def init_params(self):
     ctx = MainConfigContext.get_instance()
     self._max_queue_size = ctx.get_property('output.queue.max-size')
     self._max_consumers_size = ctx.get_property('output.consumer.max-size')
     self._autopublishing = ctx.get_property('output.autopublishing')
Exemplo n.º 6
0
    def test_should_info_returns_string_value_of_context_state(self):
        config = MainConfigContext.get_instance()
        config.scan_paths()
        result = config.info()

        self.assertIsNotNone(result)
Exemplo n.º 7
0
    def test_should_get_default_config_file_from_this_project_if_path_is_not_specified(
            self):
        config = MainConfigContext.get_instance()
        result = config.scan_paths()

        self.assertTrue(result)
Exemplo n.º 8
0
    def test_all_path_should_return_paths_to_search_in_correct_order(self):
        paths = MainConfigContext.get_instance().all_paths()

        self.assertEqual(3, len(paths))
Exemplo n.º 9
0
 def test_should_raise_when_try_to_instantiate_by_constructor(self):
     with self.assertRaises(RuntimeError):
         MainConfigContext()
Exemplo n.º 10
0
    def test_should_lazy_instantiate_singleton_class_with_success(self):
        config = MainConfigContext.get_instance()

        self.assertIsNotNone(config)
Exemplo n.º 11
0
 def get(self):
     return jsonify(MainConfigContext.get_instance().info())