Skip to content

Commit

Permalink
Allow ApplicationFacade set_config with non-string values
Browse files Browse the repository at this point in the history
Fixes #388
  • Loading branch information
cderici committed Sep 9, 2021
1 parent 687b273 commit eda2f4f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion juju/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,12 @@ async def set_config(self, config):
log.debug(
'Setting config for %s: %s', self.name, config)

return await app_facade.Set(application=self.name, options=config)
str_config = {}
for k, v in config.items():
if v.get('value') is not None:
str_config[k] = str(v.get('value'))

await app_facade.Set(application=self.name, options=str_config)

async def reset_config(self, to_default):
"""
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ async def test_action(event_loop):
assert 'backup' in actions.keys()


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_set_config(event_loop):
async with base.CleanModel() as model:
ubuntu_app = await model.deploy(
'percona-cluster',
application_name='mysql',
series='xenial',
channel='stable',
config={
'tuning-level': 'safest',
},
constraints={
'arch': 'amd64',
'mem': 256 * MB,
},
)

config = await ubuntu_app.get_config()
await ubuntu_app.set_config(config)

config2 = await ubuntu_app.get_config()
assert config == config2


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

0 comments on commit eda2f4f

Please sign in to comment.