def test_get_status_skip_update():
    config = config_yaml.Config(components_yaml_file=None)
    config.add(components.factory.get(**comp["wily"]))
    config.check()
    config.update_files()
    status = config.get_status()
    assert "UPDATE_SKIPPED for wily" in status
Esempio n. 2
0
def config_from_copy_of_test_dir() -> config_yaml.Config:
    test_dir = Path(tempfile.TemporaryDirectory().name)
    shutil.copytree(FIXTURE_DIR, test_dir)
    config = config_yaml.Config(test_dir / "components.yaml")
    config.git_commit = False
    config.read_from_yaml()
    return config
def test_save_files_to_yaml_wrong_file_path(tmp_path: Path):
    config = config_yaml.Config()
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].files = ["file1", "file2"]
    with pytest.raises(FileNotFoundError) as excinfo:
        config.save_to_yaml()
        assert "No config file provided" in str(excinfo.value)
def test_save_prefix_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].prefix = "version_prefix"
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert "version_prefix" in file_content
def test_use_filter_for_component_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].prefix = "v"
    config.components[0].filter = r"/^v\d+\.\d+\.\d+$/"
    config.components[0].check()
    assert config.components[0].next_version_tag == rex(
        config.components[0].filter)
def test_save_files_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].files = ["file1", "file2"]
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert "file1" in file_content
    assert "file2" in file_content
def test_exlude_versions_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].exclude_versions = ["v3.2.6"]
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert "exclude-versions:" in file_content
    assert "v3.2.6" in file_content
def test_components_list_write_read_yaml_file(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["glances"]))
    config.add(components.factory.get(**comp["logspout"]))
    dict1 = components.Component.components_to_dict(config.components)
    config.save_to_yaml()
    config.read_from_yaml()
    dict2 = components.Component.components_to_dict(config.components)
    assert dict1 == dict2
def test_save_next_version_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.add(components.factory.get(**comp["Django"]))
    to_update = config.count_components_to_update()
    assert to_update == 2
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert file_content.count("next-version:") == 2
Esempio n. 10
0
def config_from_copy_of_test_dir_with_dir_param() -> config_yaml.Config:
    test_dir = Path(tempfile.TemporaryDirectory().name)
    shutil.copytree(FIXTURE_DIR, test_dir)
    os.makedirs(test_dir / "conf")
    shutil.move(str(test_dir / "components.yaml"),
                test_dir / "conf/components_new.yaml")
    config = config_yaml.Config(test_dir / "conf/components_new.yaml")
    config.project_dir = test_dir
    config.git_commit = False
    config.read_from_yaml()
    return config
Esempio n. 11
0
def test_save_version_pattern_to_yaml(tmp_path: Path):
    config_file = tmp_path / "components.yaml"
    config = config_yaml.Config(components_yaml_file=config_file)
    config.add(components.factory.get(**comp["logspout"]))
    config.components[0].version_pattern = "{version}:{version}"
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert "{version}:{version}" in file_content
    config.components[0].version_pattern = config.components[
        0].DEFAULT_VERSION_PATTERN
    config.save_to_yaml()
    file_content = config_file.read_text()
    assert "version-pattern" not in file_content
Esempio n. 12
0
def cli(
    ctx: Context,
    file: Optional[Path],
    destination_file: Optional[Path],
    dry_run: bool,
    print_yaml: bool,
) -> None:
    config_file: Optional[Path] = None
    if file is not None:
        config_file = Path(file).absolute()
    elif Path.cwd().absolute().joinpath("components.yaml").is_file():
        config_file = Path.cwd().absolute().joinpath("components.yaml")

    if ctx.obj is None:
        ctx.obj = {}

    ctx.obj["config"] = config_yaml.Config(components_yaml_file=config_file)
    ctx.obj["config_file"] = config_file
    ctx.obj["destination_file"] = destination_file
    ctx.obj["dry_run"] = dry_run
    ctx.obj["print_yaml"] = print_yaml
Esempio n. 13
0
def test_load_config_without_yaml_file():
    config = config_yaml.Config(components_yaml_file=None)
    config.add(components.factory.get(**comp["Django"]))
    assert config.count_components_to_update() == 1