Exemple #1
0
    def __init__(self):
        """
        Create an instance from the handler mentioned in the config file.
        """
        module, class_name = conf.events_handler_class().rsplit('.', 1)
        events_handler_module = importlib.import_module(module)
        events_handler = getattr(events_handler_module, class_name)

        self.handler = events_handler()
def test_configuration_load_not_lazy():
    a = "whoops"
    config = { conf.events_handler_class.__name__: a }
    fsrw = MagicMock()
    fsrw.path = ""
    read_lines = MagicMock(return_value=[json.dumps(config)])
    fsrw.read_lines = read_lines
    fsrw_class = MagicMock(return_value=fsrw)
    conf.override_all({conf.events_handler_class.__name__: "bar"})
    conf.load(fsrw_class)
    assert conf._overrides is not None
    assert_equals(conf._overrides, config)
    assert_equals(conf.events_handler_class(), a)