Ejemplo n.º 1
0
def test_make_bundle(directory, expected):
    verified_manifest = api.build_and_verify(source_dir=directory)

    with open(expected, "r") as expected_file:
        expected_bundle = yaml.safe_load(expected_file)
    assert unformat_bundle(
        verified_manifest.bundle) == unformat_bundle(expected_bundle)
    assert not verified_manifest.nested
    assert hasattr(verified_manifest, 'bundle')
Ejemplo n.º 2
0
def test_make_bundle_with_yaml_list(yaml_files, expected):
    yamls = []
    for file in yaml_files:
        with open(file, "r") as yaml_file:
            yamls.append(yaml_file.read())

    bundle = api.build_and_verify(yamls=yamls)

    with open(expected, "r") as expected_file:
        expected_bundle = yaml.safe_load(expected_file)
        assert unformat_bundle(bundle) == unformat_bundle(expected_bundle)
Ejemplo n.º 3
0
def test_make_bundle_with_yaml_list(yaml_files, expected):
    yamls = []
    for file in yaml_files:
        with open(file, "r") as yaml_file:
            yamls.append(yaml_file.read())

    verified_manifest = api.build_and_verify(yamls=yamls)

    with open(expected, "r") as expected_file:
        expected_bundle = yaml.safe_load(expected_file)
    assert unformat_bundle(
        verified_manifest.bundle) == unformat_bundle(expected_bundle)
    assert not verified_manifest.nested
    assert hasattr(verified_manifest, 'bundle')
Ejemplo n.º 4
0
def test_valid_bundles_with_package_name_and_repo_name_match(
        file_name, correct_repo_name):
    with open(file_name) as f:
        bundle = yaml.safe_load(f)
        bundle = unformat_bundle(bundle)
        valid, _ = ValidateCmd().validate(bundle, repository=correct_repo_name)
        assert valid
Ejemplo n.º 5
0
def test_valid_crd_versions_field(file_name):
    with open(file_name) as f:
        bundle = yaml.safe_load(f)
        bundle = unformat_bundle(bundle)
        valid, _ = ValidateCmd().validate(bundle)

    assert valid
Ejemplo n.º 6
0
def test_valid_bundles_with_multiple_packages(file_name):
    with open(file_name) as f:
        bundle = yaml.safe_load(f)
        bundle = unformat_bundle(bundle)
        valid, _ = ValidateCmd().validate(bundle)

    assert not valid
Ejemplo n.º 7
0
def test_invalid_bundle():
    bundles = ["tests/test_files/bundles/verification/invalid.bundle.yaml"]
    for bundle in bundles:
        with open(bundle) as f:
            bundle = yaml.safe_load(f)
            bundle = unformat_bundle(bundle)
            valid = ValidateCmd().validate(bundle)
            assert valid == False
Ejemplo n.º 8
0
def _test_invalid_bundle_with_log(bundleFile, logInfo):
    with open(bundleFile) as f:
        bundle = yaml.safe_load(f)
        bundle = unformat_bundle(bundle)
        module, level, message = logInfo[0], logInfo[1], logInfo[2]
        with LogCapture() as logs:
            valid, _ = ValidateCmd().validate(bundle)
        assert not valid

        # check if the input log info is present among all logs captured
        logs.check_present((module, level, message), )
Ejemplo n.º 9
0
def test_valid_bundles_with_multiple_packages(file_name):
    with open(file_name) as f:
        bundle = yaml.safe_load(f)
        bundle = unformat_bundle(bundle)

    with LogCapture() as logs:
        valid, _ = ValidateCmd().validate(bundle)

    assert not valid
    logs.check_present(
        ('operatorcourier.validate', 'ERROR',
         'Only 1 package is expected to exist per bundle, but got 2.'))
Ejemplo n.º 10
0
def test_make_bundle(directory, expected):
    bundle = api.build_and_verify(source_dir=directory)

    with open(expected, "r") as expected_file:
        expected_bundle = yaml.safe_load(expected_file)
        assert unformat_bundle(bundle) == unformat_bundle(expected_bundle)
Ejemplo n.º 11
0
def get_bundle(bundle):
    with open(bundle) as f:
        bundle = yaml.safe_load(f)
    return unformat_bundle(bundle)
Ejemplo n.º 12
0
def _test_invalid_bundle(bundleFile):
    with open(bundleFile) as f:
        bundle = yaml.safe_load(f)
        unformatted_bundle = unformat_bundle(bundle)
        valid, _ = ValidateCmd().validate(unformatted_bundle)
        assert not valid