Skip to content

Commit e0c5d8b

Browse files
authored
Merge pull request #901 from cderici/app-charm-name
#901 #### Description Adds the `charm_name` property in `Application` object, which saves people from going through the status and stripping things from the charm URL, just to get the name of the charm. Fixes #888 The issue in there was that the `FullStatus` actually returns the charm URL as the `charm` field in `[] ApplicationStatus` field, but the client is aliasing it before printing so you see only the charm name in the `juju status --format yaml` https://github.com/juju/juju/blob/87d8ddc9de5219b3a1d854e14ee4c90a7d781d25/cmd/juju/status/formatter.go#L267 #### QA Steps ``` tox -e integration -- tests/integration/test_application.py::test_app_charm_name ```
2 parents d9df8ad + 034172c commit e0c5d8b

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

juju/application.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,19 @@ async def run(self, command, timeout=None):
547547
units=[],
548548
)
549549

550+
@property
551+
def charm_name(self):
552+
"""Get the charm name of this application
553+
554+
:return str: The name of the charm
555+
"""
556+
return URL.parse(self.charm_url).name
557+
550558
@property
551559
def charm_url(self):
552-
"""Get the charm url for a given application
560+
"""Get the charm url for this application
553561
554-
:return string: The charm url for an application
562+
:return str: The charm url
555563
"""
556564
return self.safe_data['charm-url']
557565

tests/integration/test_application.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,13 @@ async def test_app_remove_wait_flag(event_loop):
285285

286286
await model.remove_application(app.name, block_until_done=True)
287287
assert a_name not in model.applications
288+
289+
290+
@base.bootstrapped
291+
@pytest.mark.asyncio
292+
async def test_app_charm_name(event_loop):
293+
async with base.CleanModel() as model:
294+
app = await model.deploy('ubuntu')
295+
await model.wait_for_idle(status="active")
296+
assert 'ubuntu' in app.charm_url
297+
assert 'ubuntu' == app.charm_name

0 commit comments

Comments
 (0)