def METHOD_NAME(stop_babysitting, build_status, vm_image_builder_result):
    db_project_object = flexmock(
        id=1,
        job_config_trigger_type=JobConfigTriggerType.pull_request,
        project_event_model_type=ProjectEventModelType.pull_request,
    )
    if not vm_image_builder_result:
        flexmock(UpdateImageBuildHelper).should_receive("vm_image_builder").and_return(
            flexmock()
            .should_receive("image_builder_request")
            .and_raise(HTTPError("unknown ex"))
            .mock()
        )
    else:
        flexmock(UpdateImageBuildHelper).should_receive("vm_image_builder").and_return(
            flexmock()
            .should_receive("image_builder_request")
            .and_return(
                flexmock()
                .should_receive("json")
                .and_return(vm_image_builder_result)
                .mock()
            )
            .mock()
        )
    flexmock(VMImageBuildResultEvent).should_receive("get_packages_config").and_return(
        flexmock(
            get_package_config_for=lambda job_config: flexmock(),
            get_job_views=lambda: [
                flexmock(
                    trigger=JobConfigTriggerType.pull_request,
                    type=JobType.vm_image_build,
                    manual_trigger=False,
                )
            ],
        )
    )
    flexmock(VMImageBuildResultEvent).should_receive(
        "job_config_trigger_type"
    ).and_return(JobConfigTriggerType.pull_request)
    flexmock(VMImageBuildTargetModel).should_receive("get_all_by_build_id").with_args(
        1
    ).and_return(
        [
            flexmock(
                status=None,
                runs=[
                    flexmock()
                    .should_receive("get_project_event_object")
                    .and_return(db_project_object)
                    .mock()
                ],
            )
            .should_receive("set_status")
            .with_args(build_status)
            .mock()
        ]
    )
    flexmock(VMImageBuildResultHandler).should_receive("report_status")
    flexmock(ServiceConfig).should_receive("get_project").and_return()
    if stop_babysitting:
        flexmock(Pushgateway).should_receive("push").once().and_return()
    assert (
        update_vm_image_build(
            1,
            flexmock(
                build_id=1,
                project_url="an url",
                target="a target",
                get_pr_id=lambda: 21,
                owner="owner",
                commit_sha="123456",
                manual_trigger=False,
            ),
        )
        == stop_babysitting
    )