Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JUJU-4204] Model.name on 2.9 #902

Merged
merged 2 commits into from Jul 12, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions juju/model.py
Expand Up @@ -1021,6 +1021,14 @@ async def get_info(self):

return self.info

@property
def name(self):
"""Return the name of this model
"""
if self._info is None:
raise JujuError("Model is not connected")
return self._info.name

@property
def info(self):
"""Return the cached client.ModelInfo object for this Model.
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/test_model.py
Expand Up @@ -21,6 +21,19 @@
from ..utils import MB, GB, TESTS_DIR, OVERLAYS_DIR, SSH_KEY, INTEGRATION_TEST_DIR


@base.bootstrapped
@pytest.mark.asyncio
async def test_model_name(event_loop):
model = Model()
with pytest.raises(JujuError):
model.name

async with base.CleanModel() as new_model:
await model.connect(new_model.name)
assert model.name == new_model.name
await model.disconnect()


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