def test_url_is_downstream(): c = get_test_config() api = get_packit_api( config=c, local_project=LocalProject( git_url="https://src.fedoraproject.org/rpms/packit"), ) assert api.downstream_local_project assert not api.upstream_local_project
def test_srpm_snapd(snapd): pc = get_local_package_config(str(snapd)) up_lp = LocalProject(working_dir=str(snapd)) c = get_test_config() api = PackitAPI(c, pc, up_lp) with cwd(snapd): path = api.create_srpm() assert path.exists() build_srpm(path)
def test_url_is_upstream(): c = get_test_config() api = get_packit_api( config=c, local_project=LocalProject( git_url="https://github.com/packit-service/ogr"), ) assert api.upstream_local_project assert not api.downstream_local_project
def api_instance(upstream_and_remote, distgit_and_remote): u, _ = upstream_and_remote d, _ = distgit_and_remote c = get_test_config() api = get_packit_api( config=c, local_project=LocalProject(working_dir=str(Path.cwd())) ) return u, d, api
def test_srpm_on_cockpit_ostree(cockpit_ostree): upstream_path, dist_git_path = cockpit_ostree pc = get_local_package_config(str(upstream_path)) up_lp = LocalProject(working_dir=str(upstream_path)) c = get_test_config() api = PackitAPI(c, pc, up_lp) with cwd(upstream_path): api.create_srpm()
def api_instance_source_git(sourcegit_n_distgit): sourcegit, distgit = sourcegit_n_distgit with cwd(sourcegit): c = get_test_config() pc = get_local_package_config(str(sourcegit)) pc.upstream_project_url = str(sourcegit) pc.dist_git_clone_path = str(distgit) up_lp = LocalProject(working_dir=str(sourcegit)) api = PackitAPI(c, pc, up_lp) return api
def distgit_instance(upstream_and_remote, distgit_and_remote, mock_remote_functionality_upstream): u, _ = upstream_and_remote d, _ = distgit_and_remote c = get_test_config() pc = get_local_package_config(str(u)) pc.dist_git_clone_path = str(d) pc.upstream_project_url = str(u) dg = DistGit(c, pc) return d, dg
def upstream_instance(upstream_n_distgit, tmpdir): with cwd(tmpdir): u, d = upstream_n_distgit c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) lp = LocalProject(working_dir=str(u)) ups = Upstream(c, pc, lp) yield u, ups
def api_instance(upstream_n_distgit): u, d = upstream_n_distgit # we need to chdir(u) because when PackageConfig is created, # it already expects it's in the correct directory old_cwd = os.getcwd() chdir(str(u)) c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) up_lp = LocalProject(working_dir=str(u)) api = PackitAPI(c, pc, up_lp) yield u, d, api chdir(old_cwd)
def test_basic_bodhi_update( upstream_n_distgit, mock_remote_functionality_upstream, branch, update_type, update_notes, koji_builds, bodhi_response, ): # https://github.com/fedora-infra/bodhi/issues/3058 from bodhi.client.bindings import BodhiClient u, d = upstream_n_distgit with cwd(u): c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) up_lp = LocalProject(working_dir=u) api = PackitAPI(c, pc, up_lp) flexmock( BodhiClient, latest_builds=lambda package: { "f29-override": "sen-0.6.0-3.fc29", "f29-updates": "sen-0.6.0-3.fc29", "f29-updates-candidate": "sen-0.6.0-3.fc29", "f29-updates-pending": "sen-0.6.0-3.fc29", "f29-updates-testing": "sen-0.6.0-3.fc29", "f29-updates-testing-pending": "sen-0.6.0-3.fc29", "f30-override": "sen-0.6.0-4.fc30", "f30-updates": "sen-0.6.0-4.fc30", "f30-updates-candidate": "sen-0.6.1-1.fc30", "f30-updates-pending": "sen-0.6.0-4.fc30", "f30-updates-testing": "sen-0.6.0-4.fc30", "f30-updates-testing-pending": "sen-0.6.0-4.fc30", }, save=lambda **kwargs: bodhi_response, ) api.create_update( dist_git_branch=branch, update_type=update_type, update_notes=update_notes, koji_builds=koji_builds, )
def test_basic_local_update_from_downstream( downstream_n_distgit, mock_downstream_remote_functionality): flexmock(LocalProject, _parse_namespace_from_git_url=lambda: None) u, d = downstream_n_distgit with cwd(u): c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) up_lp = LocalProject(working_dir=str(u)) api = PackitAPI(c, pc, up_lp) api.sync_from_downstream("master", "master", True) assert (u / "beer.spec").is_file() spec = get_specfile(str(u / "beer.spec")) assert spec.get_version() == "0.0.0"
def test_get_api(tmpdir, remotes, package_config, is_upstream): t = Path(str(tmpdir)) repo = t / "project_repo" repo.mkdir(parents=True, exist_ok=True) initiate_git_repo(repo, remotes=remotes) flexmock(utils).should_receive("get_local_package_config").and_return( package_config) c = get_test_config() api = get_packit_api(config=c, local_project=LocalProject(working_dir=str(repo))) if is_upstream: assert api.upstream_local_project else: assert api.downstream_local_project
def test_update_on_cockpit_ostree(cockpit_ostree): upstream_path, dist_git_path = cockpit_ostree def mocked_new_sources(sources=None): if not Path(sources).is_file(): raise RuntimeError("archive does not exist") flexmock(FedPKG, init_ticket=lambda x=None: None, new_sources=mocked_new_sources) flexmock( DistGit, push_to_fork=lambda *args, **kwargs: None, is_archive_in_lookaside_cache=lambda archive_path: False, upload_to_lookaside_cache=lambda path: None, download_upstream_archive=lambda: "the-archive", ) flexmock( PackitAPI, push_and_create_pr=lambda pr_title, pr_description, dist_git_branch: None, ) pc = get_local_package_config(str(upstream_path)) up_lp = LocalProject(working_dir=str(upstream_path)) c = get_test_config() api = PackitAPI(c, pc, up_lp) api._dg = DistGit(c, pc) api._dg._local_project = LocalProject(working_dir=dist_git_path) with cwd(upstream_path): api.sync_release( "master", use_local_content=False, version="179", force_new_sources=False, create_pr=True, )
def test_basic_build(upstream_n_distgit, mock_remote_functionality_upstream): u, d = upstream_n_distgit with cwd(u): c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) up_lp = LocalProject(working_dir=u) api = PackitAPI(c, pc, up_lp) flexmock(utils).should_receive("run_command").with_args( cmd=[ "fedpkg", "build", "--scratch", "--nowait", "--target", "asdqwe" ], cwd=api.dg.local_project.working_dir, error_message="Submission of build to koji failed.", fail=True, ).once() api.build("master", scratch=True, nowait=True, koji_target="asdqwe")
def test_push_updates(upstream_n_distgit, query_response, request_response): from bodhi.client.bindings import BodhiClient u, d = upstream_n_distgit with cwd(u): c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) up_lp = LocalProject(working_dir=u) api = PackitAPI(c, pc, up_lp) flexmock(BodhiClient) BodhiClient.should_receive("query").and_return(query_response).once() BodhiClient.should_receive("request").with_args( update="FEDORA-2019-89c99f680c", request="stable" ).and_return(request_response).once() api.push_updates()
def test_basic_local_update(upstream_n_distgit, mock_remote_functionality_upstream): """ basic propose-update test: mock remote API, use local upstream and dist-git """ u, d = upstream_n_distgit with cwd(u): c = get_test_config() pc = get_local_package_config(str(u)) pc.upstream_project_url = str(u) pc.dist_git_clone_path = str(d) up_lp = LocalProject(working_dir=str(u)) api = PackitAPI(c, pc, up_lp) api.sync_release("master", "0.1.0") assert (d / TARBALL_NAME).is_file() spec = get_specfile(str(d / "beer.spec")) assert spec.get_version() == "0.1.0" assert (d / "README.packit").is_file() # assert that we have changelog entries for both versions changelog = "\n".join(spec.spec_content.section("%changelog")) assert "0.0.0" in changelog assert "0.1.0" in changelog