Ejemplo n.º 1
0
def test_handle_rm_request(
    mock_iifbc,
    mock_alti,
    mock_uiips,
    mock_capml,
    mock_srs,
    mock_srs2,
    mock_vii,
    mock_pi,
    mock_bi,
    mock_uiibs,
    mock_oir,
    mock_prfb,
    mock_cleanup,
    binary_image,
):
    arches = {'amd64', 's390x'}
    mock_iifbc.return_value = False
    mock_prfb.return_value = {
        'arches': arches,
        'binary_image': binary_image,
        'binary_image_resolved': 'binary-image@sha256:abcdef',
        'from_index_resolved': 'from-index@sha256:bcdefg',
        'ocp_version': 'v4.6',
        'distribution_scope': 'PROD',
    }
    binary_image_config = {'prod': {'v4.6': 'some_image'}}
    build.handle_rm_request(
        ['some-operator'],
        3,
        'from-index:latest',
        binary_image,
        binary_image_config=binary_image_config,
    )

    mock_cleanup.assert_called_once()
    mock_prfb.assert_called_once_with(
        3,
        RequestConfigAddRm(
            _binary_image=binary_image,
            from_index='from-index:latest',
            overwrite_from_index_token=None,
            add_arches=None,
            binary_image_config=binary_image_config,
            distribution_scope=None,
        ),
    )
    mock_oir.assert_called_once()
    assert mock_alti.call_count == 2
    assert mock_bi.call_count == len(arches)
    assert mock_pi.call_count == len(arches)
    mock_vii.assert_not_called()
    assert mock_srs.call_count == 2
    mock_capml.assert_called_once_with(3, {'s390x', 'amd64'}, None)
    mock_uiips.assert_called_once()
    assert mock_srs.call_args[0][1] == 'complete'
Ejemplo n.º 2
0
def test_handle_rm_request(mock_frpb, mock_capml, mock_srs, mock_vii, mock_pi,
                           mock_bi, mock_oir, mock_prfb, mock_cleanup):
    arches = {'amd64', 's390x'}
    mock_prfb.return_value = {
        'arches': arches,
        'binary_image_resolved': 'binary-image@sha256:abcdef',
        'from_index_resolved': 'from-index@sha256:bcdefg',
    }
    build.handle_rm_request(['some-operator'], 'binary-image:latest', 3,
                            'from-index:latest')

    mock_cleanup.assert_called_once()
    mock_prfb.assert_called_once()
    mock_oir.assert_called_once()
    assert mock_bi.call_count == len(arches)
    assert mock_pi.call_count == len(arches)
    mock_vii.assert_called_once()
    mock_srs.assert_called_once()
    mock_capml.assert_called_once()
    mock_frpb.assert_called_once()
Ejemplo n.º 3
0
def test_handle_rm_request_fbc(
    mock_ogd,
    mock_om,
    mock_ghid,
    mock_iifbc,
    mock_alti,
    mock_uiips,
    mock_capml,
    mock_srs,
    mock_srs2,
    mock_vii,
    mock_pi,
    mock_bi,
    mock_runcmd,
    mock_orrf,
    mock_uiibs,
    mock_prfb,
    mock_c,
):
    mock_iifbc.return_value = True
    mock_prfb.return_value = {
        'arches': {'amd64', 's390x'},
        'binary_image': 'binary-image:latest',
        'binary_image_resolved': 'binary-image@sha256:abcdef',
        'from_index_resolved': 'from-index@sha256:bcdefg',
        'ocp_version': 'v4.6',
        'distribution_scope': 'PROD',
    }
    mock_ghid.return_value = "/tmp/xyz/database/index.db"
    mock_ogd.return_value = "/tmp/xyz/index.Dockerfile"
    mock_om.return_value = "/tmp/xyz/catalog"
    mock_orrf.return_value = "/tmp/xyz/index.Dockerfile"
    build.handle_rm_request(
        operators=['some-operator'],
        request_id=5,
        from_index='from-index:latest',
        binary_image='binary-image:latest',
        binary_image_config={'prod': {
            'v4.6': 'some_image'
        }},
    )
    mock_prfb.assert_called_once_with(
        5,
        RequestConfigAddRm(
            _binary_image='binary-image:latest',
            from_index='from-index:latest',
            overwrite_from_index_token=None,
            add_arches=None,
            binary_image_config={'prod': {
                'v4.6': 'some_image'
            }},
            distribution_scope=None,
        ),
    )
    mock_orrf.assert_called_once()
    assert mock_alti.call_count == 2
    assert mock_bi.call_count == 2
    assert mock_pi.call_count == 2
    assert mock_srs.call_count == 2
    mock_capml.assert_called_once_with(5, {'s390x', 'amd64'}, None)
    mock_uiips.assert_called_once()
    assert mock_srs.call_args[0][1] == 'complete'