def test_package_version(db, dao: Dao, channel_name, package_name, package_with_versions): res = dao.get_package_versions(package_with_versions) res_versions = [(VersionOrder(x[0].version), x[0].build_number) for x in res] assert sorted(res_versions, reverse=True) == res_versions
def get_package_versions( package: db_models.Package = Depends(get_package_or_fail), dao: Dao = Depends(get_dao), time_created__ge: datetime.datetime = None, ): version_profile_list = dao.get_package_versions(package, time_created__ge) version_list = [] for version, profile, api_key_profile in version_profile_list: version_data = rest_models.PackageVersion.from_orm(version) version_list.append(version_data) return version_list
def get_package_versions( package: db_models.Package = Depends(get_package_or_fail), dao: Dao = Depends(get_dao)): version_profile_list = dao.get_package_versions(package) version_list = [] for version, profile, api_key_profile in version_profile_list: # TODO: don't abuse db models for this. version.id = str(uuid.UUID(bytes=version.id)) version.info = json.loads(version.info) version.uploader = profile if profile else api_key_profile version_list.append(version) return version_list
def test_package_version(db, dao: Dao, user, channel_name, package_name): channel_data = Channel(name=channel_name, private=False) package_data = Package(name=package_name) dao.create_channel(channel_data, user.id, "owner") package = dao.create_package(channel_name, package_data, user.id, "owner") package_format = "tarbz2" package_info = "{}" versions = [ ("0.1.0", 0), ("1.0.0", 0), ("0.0.1", 0), ("0.0.2", 0), ("0.0.3", 0), ("1.0.0", 1), ("1.0.0", 2), ("0.1.0", 5), ("0.1.0", 2), ] for ver, build_str in versions: dao.create_version( channel_name, package_name, package_format, "linux-64", ver, build_str, "", f"{package_name}-{ver}-{build_str}.tar.bz2", package_info, user.id, size=0, ) res = dao.get_package_versions(package) res_versions = [(VersionOrder(x[0].version), x[0].build_number) for x in res] assert sorted(res_versions, reverse=True) == res_versions