Example #1
0
def test_build(tmpdir):
    temp_dir = tmpdir.mkdir('mazer_test_build_unit_test')
    build_context = _build_context(output_path=temp_dir.strpath)
    collection_info = _collection_info()
    build_ = build.Build(build_context, collection_info)

    log.debug('build_: %s', build_)
    assert isinstance(build_, build.Build)
    assert isinstance(build_.build_context, BuildContext)
Example #2
0
def test_build_run(tmpdir):
    temp_dir = tmpdir.mkdir('mazer_test_build_run_unit_test')
    build_context = _build_context(output_path=temp_dir.strpath)
    collection_info = _collection_info()
    build_ = build.Build(build_context, collection_info)

    res = build_.run(display_callback)

    assert isinstance(res, build.BuildResult)
    assert isinstance(res.manifest, CollectionArtifactManifest)
    assert isinstance(res.manifest.collection_info, CollectionInfo)
    assert isinstance(res.manifest.files, list)

    assert res.manifest.collection_info == collection_info

    for manifest_file in res.manifest.files:
        if manifest_file.ftype == 'file':
            assert manifest_file.chksum_type == 'sha256'

    file_names = [x.name for x in res.manifest.files if x.ftype == 'file']
    dir_names = [x.name for x in res.manifest.files if x.ftype == 'dir']

    log.debug('file_names: %s', file_names)
    log.debug('dir_names: %s', dir_names)

    assert 'roles/some_role/meta/main.yml' in file_names
    assert 'galaxy.yml' in file_names
    assert 'roles' in dir_names
    assert 'roles/some_role/defaults' in dir_names

    assert isinstance(res.messages, list)

    # verify the output file got created
    artifact_file_path = res.artifact_file_path
    assert os.path.isfile(artifact_file_path)
    assert tarfile.is_tarfile(artifact_file_path)

    log.debug('results.errors: %s', res.errors)