Beispiel #1
0
def test_get_version_rhel_8():
    flexmock(buildah_builder,
             run_cmd=lambda *args, **kwargs: BUILDAH_15_VERSION)
    b = BuildahBuilder(Build(), debug=True)
    version = b.get_buildah_version()
    assert [x for x in version if isinstance(x, int)]
    assert version < (1, 7, 3)
def test_find_py_intrprtr_in_fedora_image(image_name, found):
    build = Build()
    build.base_image = image_name
    build.target_image = "starena"
    bb = BuildahBuilder(build)
    try:
        assert bb.find_python_interpreter()
    except RuntimeError:
        if found:
            # interpreter should have been found
            raise
Beispiel #3
0
def test_buildah_sanity_check_extra_args(caplog):
    set_logging(level=logging.DEBUG)
    build = Build()
    build.base_image = base_image
    build.buildah_from_extra_args = "--help"
    b = BuildahBuilder(build, debug=True)
    b.ansible_host = "cacao"
    with pytest.raises(CalledProcessError):
        b.sanity_check()
    for r in caplog.records:
        if "-h, --help" in r.message:
            break
    else:
        assert 1/0, "it seems that buildah_from_extra_args were not passed to sanity check"
Beispiel #4
0
def test_get_version():
    b = BuildahBuilder(Build(), debug=True)
    version = b.get_buildah_version()
    assert [x for x in version if isinstance(x, int)]
Beispiel #5
0
def test_build_pulls_base_img_if_not_present(application, build,
                                             is_base_present, times_called):
    build.base_image = "very-good/and-warm:mead"

    flexmock(BuildahBuilder)
    BuildahBuilder.should_receive("is_base_image_present").and_return(
        is_base_present).once()
    BuildahBuilder.should_receive("pull").times(times_called)
    BuildahBuilder.should_receive("check_container_creation").and_return(
        None).once()
    BuildahBuilder.should_receive("get_image_id").and_return("1").once()
    BuildahBuilder.should_receive("find_python_interpreter").and_return(
        "").once()
    BuildahBuilder.should_receive("create").once()
    BuildahBuilder.should_receive("commit").once()
    BuildahBuilder.should_receive("clean").once()

    flexmock(AnsibleRunner)
    AnsibleRunner.should_receive('build').and_return("").once()

    application.build(build)

    build = application.db.get_build(build.build_id)
    assert not build.pulled == is_base_present