def test_get_logs(client): chroot = "foo-1-x86_64" state = "pending" build_id = 2 project = GitProjectModel() project.namespace = "john-foo" project.repo_name = "bar" pr = PullRequestModel() pr.pr_id = 234 pr.project = project srpm_build = SRPMBuildModel() srpm_build.logs = "asd<br>qwe" c = CoprBuildModel() c.target = chroot c.build_id = str(build_id) c.srpm_build = srpm_build c.status = state c.web_url = ( "https://copr.fedorainfracloud.org/coprs/john-foo-bar/john-foo-bar/build/2/" ) c.build_logs_url = "https://localhost:5000/build/2/foo-1-x86_64/logs" flexmock(CoprBuildModel).should_receive("get_by_id").and_return(c) flexmock(CoprBuildModel).should_receive("get_project").and_return(project) flexmock(CoprBuildModel).should_receive("job_trigger").and_return( flexmock(get_trigger_object=lambda: pr)) url = f"/copr-build/1/logs" logs_url = get_copr_build_log_url_from_flask(1) assert logs_url.endswith(url) resp = client.get(url) expected = ( "<html><head>" f"<title>COPR build {project.namespace}/{project.repo_name}:" f" PR #{pr.pr_id}</title></head><body>" f"COPR build ID: {c.build_id}<br>" f"Submitted: {optional_time(c.build_submitted_time)}<br>" f"State: {c.status}<br><br>" f'Build web interface URL: <a href="{c.web_url}">{c.web_url}</a><br>' f'Build logs: <a href="{c.build_logs_url}">{c.build_logs_url}</a><br>' "SRPM creation logs:<br><br>" f"<pre>{c.srpm_build.logs}</pre>" "<br></body></html>") assert resp.data == expected.encode()
def test_get_logs(client): chroot = "foo-1-x86_64" state = "success" build_id = 2 project = GitProjectModel() project.namespace = "john-foo" project.repo_name = "bar" pr = PullRequestModel() pr.pr_id = 234 pr.project = project srpm = SRPMBuildModel() srpm.url = "https://some.random.copr.subdomain.org/my_srpm.srpm" c = CoprBuildModel() c.target = chroot c.build_id = str(build_id) c.srpm_build_id = 11 c.status = state c.srpm_build = srpm c.web_url = ( "https://copr.fedorainfracloud.org/coprs/john-foo-bar/john-foo-bar/build/2/" ) c.build_logs_url = "https://localhost:5000/build/2/foo-1-x86_64/logs" c.owner = "packit" c.project_name = "example_project" flexmock(CoprBuildModel).should_receive("get_by_id").and_return(c) flexmock(CoprBuildModel).should_receive("get_project").and_return(project) flexmock(CoprBuildModel).should_receive("job_trigger").and_return( flexmock(get_trigger_object=lambda: pr)) url = "/copr-build/1" logs_url = get_copr_build_info_url_from_flask(1) assert logs_url.endswith(url) resp = client.get(url).data.decode() assert f"srpm-build/{c.srpm_build_id}/logs" in resp assert c.web_url in resp assert c.build_logs_url in resp assert c.target in resp assert "Status: success" in resp assert "You can install" in resp assert "Download SRPM" in resp assert srpm.url in resp
def test_get_logs(client): chroot = "foo-1-x86_64" state = "pending" build_id = 2 project = GitProjectModel() project.namespace = "john-foo" project.repo_name = "bar" pr = PullRequestModel() pr.pr_id = 234 pr.project = project c = CoprBuildModel() c.target = chroot c.build_id = str(build_id) c.srpm_build_id = 11 c.status = state c.web_url = ( "https://copr.fedorainfracloud.org/coprs/john-foo-bar/john-foo-bar/build/2/" ) c.build_logs_url = "https://localhost:5000/build/2/foo-1-x86_64/logs" flexmock(CoprBuildModel).should_receive("get_by_id").and_return(c) flexmock(CoprBuildModel).should_receive("get_project").and_return(project) flexmock(CoprBuildModel).should_receive("job_trigger").and_return( flexmock(get_trigger_object=lambda: pr)) url = "/copr-build/1" logs_url = get_copr_build_info_url_from_flask(1) assert logs_url.endswith(url) resp = client.get(url).data.decode() assert f"srpm-build/{c.srpm_build_id}/logs" in resp assert c.web_url in resp assert c.build_logs_url in resp assert c.target in resp