diff --git a/src/mainframe/endpoints/package.py b/src/mainframe/endpoints/package.py index 790e68d0..b6233f83 100644 --- a/src/mainframe/endpoints/package.py +++ b/src/mainframe/endpoints/package.py @@ -173,14 +173,12 @@ def lookup_package_info( query = query.where(Scan.finished_at >= dt.datetime.fromtimestamp(since, tz=dt.timezone.utc)) with session, session.begin(): - log.info("Package info queried") params = Params(page=page, size=size) return paginate( session, query, params=params, transformer=lambda items: [Package.from_db(item) for item in items] ) - def _deduplicate_packages(packages: list[PackageSpecifier], session: Session) -> set[tuple[str, str]]: name_ver = {(p.name, p.version) for p in packages} scalars = session.scalars(select(Scan).where(tuple_(Scan.name, Scan.version).in_(name_ver))) diff --git a/tests/test_package.py b/tests/test_package.py index b081d7ee..802e03a9 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -54,16 +54,16 @@ def test_package_lookup( test_data: list[Scan], db_session: Session, ): - expected_scans = [ + expected_scans = { (scan.name, scan.version) for scan in test_data if (since is None or (scan.finished_at is not None and since <= int(scan.finished_at.timestamp()))) and (name is None or scan.name == name) and (version is None or scan.version == version) - ] + } actual_scans = lookup_package_info(db_session, since, name, version, page, size) - assert set(expected_scans) == {(scan.name, scan.version) for scan in actual_scans.items} + assert expected_scans == {(scan.name, scan.version) for scan in actual_scans.items} @pytest.mark.parametrize( @@ -109,7 +109,7 @@ def test_package_lookup_files(db_session: Session): with db_session.begin(): db_session.add(scan) - package = lookup_package_info(db_session, name="abc", version="1.0.0")[0] + package = lookup_package_info(db_session, name="abc", version="1.0.0").items[0] assert package.distributions == distros