Skip to content

Commit

Permalink
require gbpcli 2.x
Browse files Browse the repository at this point in the history
Now that 2.0.0 is released.
  • Loading branch information
enku committed Jan 19, 2024
1 parent c1ccc94 commit 52cb05f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 78 deletions.
117 changes: 64 additions & 53 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"python-dispatch>=0.2.1",
"requests",
"yarl!=1.9.1",
"gbpcli>=1.7.0",
"gbpcli>=2.0.0",
"orjson>=3.9.1",
]
requires-python = ">=3.11"
Expand Down
12 changes: 1 addition & 11 deletions src/gentoo_build_publisher/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,5 @@
def get_dist_query(
name: str, gbp: GBP, distribution: str = "gentoo_build_publisher"
) -> Query:
"""Return the Query with the given name
This function has a side-effect on pre 2.0 versions of gbpcli in that it mutates the
gbp argument to point to the given distribution's query database.
"""
if hasattr(gbp.query, "_distribution"):
# Older GBP can only see the queries for the "gbpcli" distribution and need to
# be overridden to see queries from other distributions
gbp.query._distribution = distribution # pylint: disable=protected-access
return cast(Query, getattr(gbp.query, name))

"""Return the Query with the given name"""
return cast(Query, getattr(getattr(gbp.query, distribution), name))
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def close(self) -> None:

def test_gbp(url: str) -> GBP:
"""Return a gbp instance capable of calling the /graphql view"""
gbp = GBP(url, distribution="gentoo_build_publisher")
gbp = GBP(url)
gbp.query._session.mount( # pylint: disable=protected-access
url, DjangoToRequestsAdapter()
)
Expand Down
13 changes: 1 addition & 12 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,8 @@
class GetDistQueryTests(TestCase):
"""Tests for the get_dist_query helper"""

def test_old_world(self) -> None:
# Pre gbpcli-2.0
def test(self) -> None:
gbp = test_gbp("http://test.invalid/")
query = get_dist_query(
"create_repo", gbp, distribution="gentoo_build_publisher"
)

self.assertEqual(str(query), CREATE_MACHINE_QUERY_STR)

def test_new_world(self) -> None:
# post gbpcli-2.0. Not yet released so we mock the expected behavior
gbp = mock.MagicMock()
del gbp.query._distribution
gbp.query.gentoo_build_publisher.create_repo = Query(
CREATE_MACHINE_QUERY_STR, "http://test.invalid", mock.Mock()
)
Expand Down

0 comments on commit 52cb05f

Please sign in to comment.