Skip to content

Commit 914e3b4

Browse files
authored
Merge pull request #854 from cderici/fix-type-parsing-in-facade.py
#854 #### Description This fixes a bug found in the `facade.py` parsing simple entries in the `Type.from_json()` function. Should fix #850 & #851 #### QA Steps To go with the same way of #850 and #851 to reproduce this, using juju `2.9.42`, bootstrap a k8s model (I did it on microk8s). ```sh $ juju bootstrap microk8s removeme ``` Then get a libjuju console on the toplevel dir: ```sh $ python -m asyncio ``` Then the following should work just fine: ```sh from juju import model;m = model.Model(); await m.connect(); await m.deploy("postgresql", channel="14/edge") ``` Also added an integration test that should work (fails without this change): ```tox tox -e integration -- tests/integration/test_model.py::test_deploy_charm_assumes ``` which just runs `await model.deploy('postgresql', channel='14/edge')` Note that this is not the ideal test because it depends on that the upstream charm having the simple assumes: -juju expression. However, simulating the bug in the facade.py for parsing such expressions is non-trivial as we need a test to call something like the CharmsFacade.CharmInfo() to trigger parsing the metadata (which is actually where it fails in the reported bug). Creating a local charm wouldn't work because we locally handle the metadata (wihtout going through anything in the facade.py where the bug is located). Maybe we can manually call AddCharm in the test for a local charm and then manually call the CharmInfo with the returned url. All CI tests need to pass. #### Notes & Discussion This will need to be forward ported into the master.
2 parents a531e4b + 4b4f60c commit 914e3b4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

juju/client/facade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def from_json(cls, data):
689689
cls.splitEntries(v, d)
690690
else:
691691
# this is a simple entry
692-
cls.splitEntries(v, d)
692+
cls.splitEntries(entry, d)
693693
return cls(**d)
694694
return None
695695

tests/integration/test_model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ async def test_deploy_local_charm(event_loop):
149149
assert model.units['charm/0'].workload_status == 'active'
150150

151151

152+
@base.bootstrapped
153+
@pytest.mark.asyncio
154+
async def test_deploy_charm_assumes(event_loop):
155+
async with base.CleanModel() as model:
156+
await model.deploy('postgresql', channel='14/edge')
157+
158+
152159
@base.bootstrapped
153160
@pytest.mark.asyncio
154161
async def test_deploy_local_charm_channel(event_loop):

0 commit comments

Comments
 (0)