def _populate_lockfile_repo(self, repo: LockfileRepository, ops: Sequence[Operation]) -> None: for op in ops: if isinstance(op, Uninstall): continue elif isinstance(op, Update): package = op.target_package else: package = op.package if not repo.has_package(package): repo.add_package(package)
def test_has_package(): repo = LockfileRepository() url_package = Package("a", "1.0", source_type="url", source_url="https://example.org/a.whl") assert not repo.has_package(url_package) repo.add_package(url_package) pypi_package = Package("a", "1.0") assert not repo.has_package(pypi_package) repo.add_package(pypi_package) url_package_2 = Package("a", "1.0", source_type="url", source_url="https://example.org/a-1.whl") assert not repo.has_package(url_package_2) repo.add_package(url_package_2) assert len(repo.packages) == 3 assert repo.has_package(deepcopy(url_package)) assert repo.has_package(deepcopy(pypi_package)) assert repo.has_package(deepcopy(url_package_2))