Skip to content

Commit f34b91d

Browse files
authored
Merge branch 'master' into app-refresh-with-resources-on-3.x
2 parents fb6099b + 9e0e39d commit f34b91d

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

examples/local_refresh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def main():
2020

2121
try:
2222
print('Get deployed application')
23-
app = model.appplications["ubuntu"]
23+
app = model.applications["ubuntu"]
2424

2525
print('Refresh/Upgrade Ubuntu charm with local charm')
2626
await app.refresh(path="path/to/local/ubuntu.charm")

juju/application.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,17 @@ async def local_refresh(
863863
metadata,
864864
resources=resources)
865865

866+
# We know this charm is a local charm, but this charm origin could be
867+
# the charm origin of a charmhub charm. Ensure that we update/remove
868+
# the appropriate fields.
869+
charm_origin.source = "local"
870+
charm_origin.track = None
871+
charm_origin.risk = None
872+
charm_origin.branch = None
873+
charm_origin.hash_ = None
874+
charm_origin.id_ = None
875+
charm_origin.revision = URL.parse(charm_url).revision
876+
866877
set_charm_args = {
867878
'application': self.entity_id,
868879
'charm_origin': charm_origin,

tests/integration/test_application.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .. import base
1010
from juju import jasyncio, errors
1111
from juju.url import URL, Schema
12+
from juju.client import client
1213

1314
MB = 1
1415

@@ -265,6 +266,22 @@ async def test_refresh_charmhub_to_local(event_loop):
265266
assert app.data['charm-url'].startswith('local:')
266267

267268

269+
@base.bootstrapped
270+
@pytest.mark.asyncio
271+
async def test_local_refresh(event_loop):
272+
charm_path = INTEGRATION_TEST_DIR / 'charm'
273+
async with base.CleanModel() as model:
274+
app = await model.deploy('ubuntu')
275+
origin = client.CharmOrigin(source="charm-hub", track="20.04", risk="stable",
276+
branch="deadbeef", hash_="hash", id_="id", revision=12,
277+
base=client.Base("20.04", "ubuntu"))
278+
279+
await app.local_refresh(charm_origin=origin, path=charm_path)
280+
281+
assert origin == client.CharmOrigin(source="local", revision=0,
282+
base=client.Base("20.04", "ubuntu"))
283+
284+
268285
@base.bootstrapped
269286
@pytest.mark.asyncio
270287
async def test_trusted(event_loop):

0 commit comments

Comments
 (0)