Example #1
0
 def test_release_prettifying(self):
     pretty_release = TestPrettier.get_yaml_string("pretty_release.yml")
     self.assertEqual(
         prettier(load_yaml(os.path.join(INPUT_FOLDER,
                                         "ugly_release.yml"))),
         pretty_release,
     )
Example #2
0
def test_unused_versions():
    files = [
        os.path.join(_get_test_root(),
                     "data/test_releases/2020.01.a1-py27.yml"),
        os.path.join(_get_test_root(),
                     "data/test_releases/2020.01.a1-py36.yml"),
    ]
    used_versions = load_all_releases(files)

    repository = _load_yaml(
        os.path.join(_get_test_root(), "data/test_repository.yml"))
    unused_versions = find_unused_versions(used_versions, repository)
    print(prettier(repository))
    print(used_versions)
    print(unused_versions)
    assert "0.0.2" in unused_versions["lib1"]
    assert "0.0.2" in unused_versions["lib2"]
    assert "master" in unused_versions["lib3"]
    assert "lib4" not in unused_versions
    assert "1.2.3" in unused_versions["lib5"]
Example #3
0
def run_cleanup(args, parser):
    if args.check and args.stdout:
        parser.error(
            ArgumentError(
                message="Only check, stdout can not be used together!",
                argument=args.check,
            ))
    repository = load_yaml(args.repository)
    release_files = [
        filename for sublist in args.releases for filename in sublist
    ]
    used_versions = load_all_releases(release_files)
    unused_versions = find_unused_versions(used_versions, repository)

    if args.check:
        if not unused_versions:
            print("No unused software versions found!")
        else:
            print("The following software version are not in use:")
        for lib, versions in unused_versions.items():
            print(lib, versions)
        return

    remove_unused_versions(repository=repository,
                           unused_versions=unused_versions)

    if args.stdout:
        print(prettier(repository))
        return

    output_file = args.repository
    if args.output:
        output_file = args.output
    write_to_file(repository, output_file)
    if unused_versions:
        print("Success! New repository file written to {}".format(output_file))
        print("The following software version are not in use:")
        for lib, versions in unused_versions.items():
            print(lib, versions)
Example #4
0
 def test_inconsistent_config(self):
     with self.assertRaises(ValueError):
         prettier(
             load_yaml(os.path.join(INPUT_FOLDER,
                                    "inconsistent_config.yml")))