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')
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)
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')
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
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
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
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
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), )
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.'))
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)
def get_bundle(bundle): with open(bundle) as f: bundle = yaml.safe_load(f) return unformat_bundle(bundle)
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