def METHOD_NAME(zip_builder, api_deploy):
    pc = mock.Mock()
    org = mock.Mock()
    api_deploy.return_value.side_effect = [
        MetadataApiError("invalid cross reference id", None),
        None,
    ]
    install_package_by_namespace_version(
        pc,
        org,
        "foo",
        "1.0",
        PackageInstallOptions(),
    )
    context = TaskContext(
        org_config=org,
        project_config=pc,
        logger=getLogger("cumulusci.salesforce_api.package_install"),
    )
    api_deploy.assert_has_calls(
        [
            mock.call(context, mock.ANY, purge_on_delete=False),
            mock.call(context, mock.ANY, purge_on_delete=False),
        ],
        any_order=True,
    )
    api_deploy.return_value.assert_has_calls([mock.call(), mock.call()])