Skip to content

Commit

Permalink
add 'version' property to /api/v2/packages/ response
Browse files Browse the repository at this point in the history
Signed-off-by: Erol Keskin <[email protected]>
  • Loading branch information
erolkskn authored and mergify[bot] committed Aug 29, 2022
1 parent d1351a5 commit 827fe4d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions anitya/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def get(self):
"name": "python-requests"
"project": "requests",
"ecosystem": "pypi",
"version": "2.28.1"
}
],
"items_per_page": 25,
Expand Down Expand Up @@ -166,6 +167,7 @@ def get(self):
"name": package.package_name,
"project": package.project.name,
"ecosystem": package.project.ecosystem_name,
"version": package.project.latest_version,
}
for package in page.items
],
Expand Down
41 changes: 35 additions & 6 deletions anitya/tests/test_flask_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def test_authenticated(self):
def test_packages(self):
"""Assert packages are returned when they exist."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand Down Expand Up @@ -115,18 +118,21 @@ def test_packages(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
{
"distribution": "Debian",
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
{
"distribution": "jcline linux",
"name": "requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
],
}
Expand All @@ -136,7 +142,10 @@ def test_packages(self):
def test_filter_packages_by_name(self):
"""Assert filtering packages by name works."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand Down Expand Up @@ -164,12 +173,14 @@ def test_filter_packages_by_name(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
{
"distribution": "Debian",
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
],
}
Expand All @@ -179,7 +190,10 @@ def test_filter_packages_by_name(self):
def test_filter_packages_by_name_case_insensitive(self):
"""Assert filtering packages by case insensitive name works."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand Down Expand Up @@ -207,12 +221,14 @@ def test_filter_packages_by_name_case_insensitive(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
{
"distribution": "Debian",
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
},
],
}
Expand All @@ -233,7 +249,10 @@ def test_list_packages_items_per_page_no_items(self):
def test_list_packages_items_per_page(self):
"""Assert pagination works and page size is adjustable."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand All @@ -257,6 +276,7 @@ def test_list_packages_items_per_page(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
}
],
}
Expand All @@ -266,7 +286,10 @@ def test_list_packages_items_per_page(self):
def test_list_packages_items_per_page_with_page(self):
"""Assert retrieving other pages works."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand All @@ -290,6 +313,7 @@ def test_list_packages_items_per_page_with_page(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
}
],
}
Expand All @@ -299,7 +323,10 @@ def test_list_packages_items_per_page_with_page(self):
def test_filter_distribution(self):
"""Assert retrieving other pages works."""
project = models.Project(
name="requests", homepage="https://pypi.io/project/requests", backend="PyPI"
name="requests",
homepage="https://pypi.io/project/requests",
backend="PyPI",
latest_version="1",
)
fedora_package = models.Packages(
distro_name="Fedora", project=project, package_name="python-requests"
Expand All @@ -326,6 +353,7 @@ def test_filter_distribution(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
}
],
}
Expand All @@ -339,6 +367,7 @@ def test_filter_distribution(self):
"name": "python-requests",
"project": "requests",
"ecosystem": "pypi",
"version": "1",
}
],
}
Expand Down
1 change: 1 addition & 0 deletions news/1442.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/api/v2/packages/ endpoint now returns latest version info too.

0 comments on commit 827fe4d

Please sign in to comment.