def test_api(): dut = YamlConfigLoader() config = dut.load_config(path_to_config('config.api.none.yaml')) assert config.api is None config = dut.load_config(path_to_config('config.api.min.yaml')) assert config.api == APIModel(port=12345, enable_metrics=False) config = dut.load_config(path_to_config('config.api.max.yaml')) assert config.api == APIModel(port=23456, enable_metrics=True)
def test_yaml_tag_env_with_envvar_not_set(): dut = YamlConfigLoader() with pytest.raises( OSError, match= "Environment variable 'REPEAT_STR' not found and no default set"): config = dut.load_config(path_to_config('yaml_tag_env/config.yaml'))
def test_load_config(): dut = YamlConfigLoader() config = dut.load_config(path_to_config('config.simple.json')) assert config.engine is None assert list(config.tasks.keys()) == ['simple'] simple_task = config.tasks['simple'] assert isinstance(simple_task.pull.instance, Count) assert len(simple_task.pushes) == 1 assert isinstance(simple_task.pushes[0].instance, Echo)
def test_yaml_tag_include(): dut = YamlConfigLoader() config = dut.load_config(path_to_config('yaml_tag_include/config.yaml')) assert config is not None task = config.tasks.get('include_tag') assert task assert str(task.pull.instance) == str( Repeat("Hello World", name="include_tag_pull", interval="1s")) assert len(task.pushes) == 1 assert str(task.pushes[0].instance) == str(Echo(name="include_tag_push_0"))
def test_load_config_push_with_deps(config, cnt_deps): dut = YamlConfigLoader() config = dut.load_config(path_to_config(config)) assert list(config.tasks.keys()) == ['pytest'] simple_task = config.tasks['pytest'] assert isinstance(simple_task.pull.instance, Count) assert len(simple_task.pushes) == 1 assert isinstance(simple_task.pushes[0].instance, Echo) assert len(simple_task.pushes[0].deps) == cnt_deps for dependency in simple_task.pushes[0].deps: assert isinstance(dependency, PushModel) assert isinstance(dependency.instance, Echo)
def test_load_config_with_engine(): dut = YamlConfigLoader() config = dut.load_config(path_to_config('config.engine.yaml')) engine = config.engine tasks = config.tasks assert engine is not None assert isinstance(engine, AsyncEngine) assert isinstance(engine.retry_handler, SimpleRetryHandler) assert engine.retry_handler.retry_wait == 60 assert list(tasks.keys()) == ['pytest'] simple_task = tasks['pytest'] assert simple_task.name == 'pytest'
def test_yaml_tag_env_with_envvar_set(): dut = YamlConfigLoader() with modified_environ(REPEAT_STR="Repeat me!"): config = dut.load_config(path_to_config('yaml_tag_env/config.yaml')) assert config is not None task_wo_default = config.tasks.get('env_tag_wo_default') assert task_wo_default assert str(task_wo_default.pull.instance) == str( Repeat("Repeat me!", name="env_tag_wo_default_pull", interval="1s")) task_w_default = config.tasks.get('env_tag_with_default') assert task_w_default assert str(task_w_default.pull.instance) == str( Repeat("the_default", name="env_tag_with_default_pull", interval="1s"))