コード例 #1
0
def test_bad_format(conf: user_config.UserConfig, schema):
    logger.debug(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    # create the notification listener factory
    authenticator = auth.Auth.get_auth(conf)
    engine_factory: ef.EngineFactory = ef.EngineFactory(conf.notification_engine, authenticator)
    listener_factory = elf.EventListenerFactory(engine_factory, schema)
    # open the listener yaml file
    with open("tests/unit/fixtures/bad/badFormat.yaml", "r") as f:
        listeners_dict = yaml.safe_load(f.read())
    # parse it
    try:
        listeners: list = listener_factory.create_listeners(listeners_dict)
    except ValueError as e:
        assert e.args[0] == "Value 2021-01-01 is not valid for key date"
コード例 #2
0
def test_no_listeners(conf: user_config.UserConfig, schema):
    logger.debug(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    # create the notification listener factory
    authenticator = auth.Auth.get_auth(conf)
    engine_factory: ef.EngineFactory = ef.EngineFactory(conf.notification_engine, authenticator)
    listener_factory = elf.EventListenerFactory(engine_factory, schema)
    # open the listener yaml file
    with open("tests/unit/fixtures/bad/noListeners.yaml", "r") as f:
        listeners_dict = yaml.safe_load(f.read())
    # parse it
    try:
        listeners: list = listener_factory.create_listeners(listeners_dict)
    except AssertionError as e:
        assert e.args[0] == "Event listeners definition must start with the keyword 'listeners'"
コード例 #3
0
def test_bad_trigger_type(conf: user_config.UserConfig, schema):
    logger.debug(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    # create the notification listener factory
    authenticator = auth.Auth.get_auth(conf)
    engine_factory: ef.EngineFactory = ef.EngineFactory(conf.notification_engine, authenticator)
    listener_factory = elf.EventListenerFactory(engine_factory, schema)
    # open the listener yaml file
    with open("tests/unit/fixtures/bad/badTriggerType.yaml", "r") as f:
        listeners_dict = yaml.safe_load(f.read())
    # parse it
    try:
        listeners: list = listener_factory.create_listeners(listeners_dict)
    except KeyError as e:
        assert e.args[0] == "Trigger type logger not recognised"
コード例 #4
0
def test_multiple_listener(conf: user_config.UserConfig, schema):
    logger.debug(os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    # create the notification listener factory
    authenticator = auth.Auth.get_auth(conf)
    engine_factory: ef.EngineFactory = ef.EngineFactory(conf.notification_engine, authenticator)
    listener_factory = elf.EventListenerFactory(engine_factory, schema)
    # open the listener yaml file
    with open("tests/unit/fixtures/multiple_flight_listeners.yaml", "r") as f:
        listeners_dict = yaml.safe_load(f.read())
    # parse it
    listeners: list = listener_factory.create_listeners(listeners_dict)
    assert listeners.__len__() == 3
    for listener in listeners:
        assert listener.keys is not None
        assert listener.keys[0]  # this will fail if the path was an empty string