Skip to content

Commit

Permalink
Merge pull request #902 from cderici/model-name-on-2.9
Browse files Browse the repository at this point in the history
#902

#### Description

Backports `model.name` from HEAD into 2.9. Gets this particular change from 55ea0e2 adds the name property into a Model object. Couldn't directly cherry pick because of the other stuff in the commit.

Fixes #893 

#### QA Steps

Also backports the integration test as well, so:

```
tox -e integration -- tests/integration/test_model.py::test_model_name
```
  • Loading branch information
jujubot authored Jul 12, 2023
2 parents e0c5d8b + f16e7aa commit 4c44e9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions juju/model.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 4c44e9b

Please sign in to comment.