Пример #1
0
def test_init_success(mock_quay_api_client, mock_quay_client):
    references = ["stage.quay.io/name/repo1:1", "stage.quay.io/name/repo2:2"]
    token = "some-token"
    quay_user = "******"
    quay_password = "******"
    host = "stage.quay.io/"
    untagger = image_untagger.ImageUntagger(references, token, False,
                                            quay_user, quay_password, host)

    assert untagger.references == references
    assert untagger.host == host[:-1]
    assert not untagger.remove_last
    mock_quay_client.assert_called_once_with(quay_user, quay_password,
                                             host[:-1])
    mock_quay_api_client.assert_called_once_with(token, host[:-1])
Пример #2
0
def test_untag_images_missing_client(manifest_list_data, caplog):
    caplog.set_level(logging.INFO)
    references = [
        "stage.quay.io/name/repo1:1",
        "stage.quay.io/name/repo1:2",
    ]
    token = "some-token"
    quay_user = "******"
    host = "stage.quay.io/"
    untagger = image_untagger.ImageUntagger(references,
                                            token,
                                            True,
                                            quay_user,
                                            host=host)
    with pytest.raises(RuntimeError, match="QuayClient instance must be set"):
        untagger.untag_images()
Пример #3
0
def setup_untagger(
    references,
    token=UNUSED,
    quay_user=UNUSED,
    quay_password=UNUSED,
    host=UNUSED,
    remove_last=UNUSED,
):
    _token = "some-token"
    _quay_user = "******"
    _quay_password = "******"
    _host = "stage.quay.io/"
    untagger = image_untagger.ImageUntagger(
        references,
        token if token is not UNUSED else _token,
        remove_last if remove_last is not UNUSED else False,
        quay_user if _quay_user is not UNUSED else _quay_user,
        quay_password if quay_password is not UNUSED else _quay_password,
        host if host is not UNUSED else _host,
    )
    return untagger