def test_koji_build_start(koji_build_scratch_start, pc_koji_build_pr, koji_build_pr): koji_build_pr.target = "rawhide" flexmock(GithubProject).should_receive("is_private").and_return(False) flexmock(KojiTaskEvent).should_receive("get_package_config").and_return( pc_koji_build_pr) flexmock(KojiBuildModel).should_receive("get_by_build_id").and_return( koji_build_pr) url = get_koji_build_info_url(1) flexmock(requests).should_receive("get").and_return(requests.Response()) flexmock( requests.Response).should_receive("raise_for_status").and_return(None) koji_build_pr.should_receive("set_build_start_time").once() koji_build_pr.should_receive("set_build_finished_time").with_args( None).once() koji_build_pr.should_receive("set_status").with_args("running").once() koji_build_pr.should_receive("set_build_logs_url") koji_build_pr.should_receive("set_web_url") # check if packit-service set correct PR status flexmock(StatusReporter).should_receive("report").with_args( state=BaseCommitStatus.running, description="RPM build is in progress...", url=url, check_names="production-build:rawhide", markdown_content=None, ).once() flexmock(Signature).should_receive("apply_async").once() flexmock(Pushgateway).should_receive("push").once().and_return() processing_results = SteveJobs().process_message(koji_build_scratch_start) event_dict, job, job_config, package_config = get_parameters_from_results( processing_results) assert json.dumps(event_dict) results = run_koji_build_report_handler( package_config=package_config, event=event_dict, job_config=job_config, ) assert first_dict_value(results["job"])["success"]
def test_koji_build_end(koji_build_scratch_end, pc_koji_build_pr, koji_build_pr): koji_build_pr.target = "rawhide" flexmock(GithubProject).should_receive("is_private").and_return(False) flexmock(KojiBuildEvent).should_receive("get_package_config").and_return( pc_koji_build_pr) flexmock(KojiBuildModel).should_receive("get_by_build_id").and_return( koji_build_pr) url = get_koji_build_info_url_from_flask(1) flexmock(requests).should_receive("get").and_return(requests.Response()) flexmock( requests.Response).should_receive("raise_for_status").and_return(None) koji_build_pr.should_receive("set_build_start_time").once() koji_build_pr.should_receive("set_build_finished_time").once() koji_build_pr.should_receive("set_status").with_args("success").once() koji_build_pr.should_receive("set_build_logs_url") koji_build_pr.should_receive("set_web_url") # check if packit-service set correct PR status flexmock(StatusReporter).should_receive("report").with_args( state=CommitStatus.success, description="RPMs were built successfully.", url=url, check_names="packit-stg/production-build-rawhide", ).once() flexmock(Signature).should_receive("apply_async").once() processing_results = SteveJobs().process_message(koji_build_scratch_end) event_dict, package_config, job = get_parameters_from_results( processing_results) results = run_koji_build_report_handler( package_config=package_config, event=event_dict, job_config=job, ) assert first_dict_value(results["job"])["success"]