Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions juju/charmhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ async def info(self, name, channel=None):
facade = self._facade()
return await facade.Info(tag="application-{}".format(name), channel=channel)

async def find(self, query):
async def find(self, query, category=None, channel=None,
charm_type=None, platforms=None, publisher=None,
relation_requires=None, relation_provides=None):
"""find queries the CharmHub store for available charms or bundles.

"""
if charm_type is not None and charm_type not in ["charm", "bundle"]:
raise JujuError("expected either charm or bundle for charm_type")

facade = self._facade()
return await facade.Find(query=query)
return await facade.Find(query=query, category=category, channel=channel,
type_=charm_type, platforms=platforms, publisher=publisher,
relation_provides=relation_provides, relation_requires=relation_requires)

def _facade(self):
return client.CharmHubFacade.from_connection(self.model.connection())
16 changes: 14 additions & 2 deletions tests/integration/test_charmhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ async def test_info_not_found(event_loop):
try:
await model.charmhub.info("badnameforapp")
except JujuAPIError as e:
assert e.message == "No charm or bundle with name 'badnameforapp'."
assert e.message == "badnameforapp not found"
else:
raise
assert False


@base.bootstrapped
Expand All @@ -47,6 +47,18 @@ async def test_find(event_loop):
assert resp.type_ in ["charm", "bundle"]


@base.bootstrapped
@pytest.mark.asyncio
async def test_find_bundles(event_loop):
async with base.CleanModel() as model:
result = await model.charmhub.find("kube", charm_type="bundle")

assert len(result.result) > 0
for resp in result.result:
assert resp.name != ""
assert resp.type_ in ["bundle"]


@base.bootstrapped
@pytest.mark.asyncio
async def test_find_all(event_loop):
Expand Down