def test_testing_farm_response( tests_result, tests_message, tests_tests, status_status, status_message ): flexmock(TFResultsHandler).should_receive( "get_package_config_from_repo" ).and_return( flexmock( jobs=[ JobConfig( type=JobType.copr_build, trigger=JobConfigTriggerType.pull_request, metadata={}, ) ], ) ) test_farm_handler = TFResultsHandler( config=flexmock(command_handler_work_dir=flexmock()), job_config=flexmock(), event=TFResultsEvent( pipeline_id="id", result=tests_result, environment=flexmock(), message=tests_message, log_url="some url", copr_repo_name=flexmock(), copr_chroot="fedora-rawhide-x86_64", tests=tests_tests, repo_namespace=flexmock(), repo_name=flexmock(), git_ref=flexmock(), https_url=flexmock(), commit_sha=flexmock(), ), ) flexmock(StatusReporter).should_receive("report").with_args( state=status_status, description=status_message, url="some url", check_names="packit-stg/testing-farm-fedora-rawhide-x86_64", ) tft_test_run_model = flexmock() tft_test_run_model.should_receive("set_status").with_args( tests_result ).and_return().once() tft_test_run_model.should_receive("set_web_url").with_args( "some url" ).and_return().once() flexmock(TFTTestRunModel).should_receive("get_by_pipeline_id").and_return( tft_test_run_model ) flexmock(LocalProject).should_receive("refresh_the_arguments").and_return(None) test_farm_handler.run()
def test_testing_farm_response( tests_result, tests_summary, status_status, status_message, ): flexmock(PackageConfigGetter).should_receive( "get_package_config_from_repo" ).and_return( flexmock( jobs=[ JobConfig( type=JobType.copr_build, trigger=JobConfigTriggerType.pull_request, ) ], ) ) config = flexmock(command_handler_work_dir=flexmock()) flexmock(TFResultsHandler).should_receive("service_config").and_return(config) flexmock(TFResultsEvent).should_receive("db_trigger").and_return(None) config.should_receive("get_project").with_args( url="https://github.com/packit/ogr" ).and_return() created_dt = datetime.utcnow() event_dict = TFResultsEvent( pipeline_id="id", result=tests_result, compose=flexmock(), summary=tests_summary, log_url="some url", copr_build_id=flexmock(), copr_chroot="fedora-rawhide-x86_64", commit_sha=flexmock(), project_url="https://github.com/packit/ogr", created=created_dt, ).get_dict() test_farm_handler = TFResultsHandler( package_config=flexmock(), job_config=flexmock(), event=event_dict ) flexmock(StatusReporter).should_receive("report").with_args( state=status_status, description=status_message, links_to_external_services={"Testing Farm": "some url"}, url="https://dashboard.localhost/results/testing-farm/123", check_names="testing-farm:fedora-rawhide-x86_64", ) urls.DASHBOARD_URL = "https://dashboard.localhost" tft_test_run_model = flexmock( id=123, submitted_time=datetime.now(), get_trigger_object=lambda: flexmock( id=12, job_config_trigger_type=JobConfigTriggerType.pull_request, job_trigger_model_type=JobTriggerModelType.pull_request, ), ) tft_test_run_model.should_receive("set_status").with_args( tests_result, created=created_dt ).and_return().once() tft_test_run_model.should_receive("set_web_url").with_args( "some url" ).and_return().once() flexmock(TFTTestRunModel).should_receive("get_by_pipeline_id").and_return( tft_test_run_model ) flexmock(JobTriggerModel).should_receive("get_or_create").and_return( flexmock(id=1, type=JobTriggerModelType.pull_request) ) flexmock(LocalProject).should_receive("refresh_the_arguments").and_return(None) test_farm_handler.run()
def test_testing_farm_response( tests_result, tests_message, tests_tests, status_status, status_message, status_url, ): flexmock(PackageConfigGetter).should_receive( "get_package_config_from_repo" ).and_return( flexmock( jobs=[ JobConfig( type=JobType.copr_build, trigger=JobConfigTriggerType.pull_request, ) ], ) ) config = flexmock(command_handler_work_dir=flexmock()) flexmock(TFResultsHandler).should_receive("service_config").and_return(config) flexmock(TFResultsEvent).should_receive("db_trigger").and_return(None) config.should_receive("get_project").with_args( url="https://github.com/packit/ogr" ).and_return() event_dict = TFResultsEvent( pipeline_id="id", result=tests_result, compose=flexmock(), summary=tests_message, log_url="some url", copr_build_id=flexmock(), copr_chroot="fedora-rawhide-x86_64", tests=tests_tests, commit_sha=flexmock(), project_url="https://github.com/packit/ogr", ).get_dict() test_farm_handler = TFResultsHandler( package_config=flexmock(), job_config=flexmock(), data=EventData.from_event_dict(event_dict), tests=tests_tests, result=tests_result, pipeline_id="id", log_url="some url", copr_chroot="fedora-rawhide-x86_64", summary=tests_message, ) flexmock(StatusReporter).should_receive("report").with_args( state=status_status, description=status_message, url=status_url, check_names="packit-stg/testing-farm-fedora-rawhide-x86_64", ) tft_test_run_model = flexmock() tft_test_run_model.should_receive("set_status").with_args( tests_result ).and_return().once() tft_test_run_model.should_receive("set_web_url").with_args( "some url" ).and_return().once() flexmock(TFTTestRunModel).should_receive("get_by_pipeline_id").and_return( tft_test_run_model ) flexmock(LocalProject).should_receive("refresh_the_arguments").and_return(None) test_farm_handler.run()