def test_check_pending_copr_builds(): build1 = flexmock(status="pending", build_id=1) build2 = flexmock(status="pending", build_id=2) build3 = flexmock(status="pending", build_id=1) flexmock(CoprBuildModel).should_receive("get_all_by_status").with_args( "pending").and_return([build1, build2, build3]) flexmock(packit_service.worker.build.babysit).should_receive( "update_copr_builds").with_args(1, [build1, build3]).once() flexmock(packit_service.worker.build.babysit).should_receive( "update_copr_builds").with_args(2, [build2]).once() check_pending_copr_builds()
def test_check_copr_build_not_exists(): flexmock(Client).should_receive("create_from_config_file").and_return( flexmock( build_proxy=flexmock().should_receive("get").with_args(1). and_raise(CoprNoResultException, "Build 1 does not exist").mock())) builds = [] for i in range(2): builds.append(flexmock(status="pending", build_id=1)) builds[i].should_receive("set_status").with_args("error").once() flexmock(CoprBuildModel).should_receive("get_all_by_status").with_args( "pending").and_return(builds) check_pending_copr_builds()
def babysit_pending_copr_builds() -> None: check_pending_copr_builds()
def test_check_pending_copr_builds_no_builds(): flexmock(CoprBuildModel).should_receive("get_all_by_status").with_args( "pending").and_return([]) flexmock(packit_service.worker.build.babysit).should_receive( "update_copr_builds").never() check_pending_copr_builds()