|
10 | 10 |
|
11 | 11 | import mock |
12 | 12 | import paramiko |
13 | | - |
14 | 13 | import pylxd |
15 | 14 | import pytest |
| 15 | + |
16 | 16 | from juju import jasyncio, tag, url |
| 17 | +from juju.application import Application |
17 | 18 | from juju.client import client |
18 | | -from juju.errors import JujuError, JujuModelError, JujuUnitError, JujuConnectionError |
| 19 | +from juju.client._definitions import FullStatus |
| 20 | +from juju.errors import (JujuConnectionError, JujuError, JujuModelError, |
| 21 | + JujuUnitError) |
19 | 22 | from juju.model import Model, ModelObserver |
20 | | -from juju.utils import block_until, run_with_interrupt, wait_for_bundle, base_channel_to_series |
| 23 | +from juju.utils import (base_channel_to_series, block_until, |
| 24 | + run_with_interrupt, wait_for_bundle) |
21 | 25 |
|
22 | 26 | from .. import base |
23 | | -from ..utils import MB, GB, TESTS_DIR, OVERLAYS_DIR, SSH_KEY, INTEGRATION_TEST_DIR |
| 27 | +from ..utils import (GB, INTEGRATION_TEST_DIR, MB, OVERLAYS_DIR, SSH_KEY, |
| 28 | + TESTS_DIR) |
24 | 29 |
|
25 | 30 |
|
26 | 31 | @base.bootstrapped |
@@ -181,6 +186,25 @@ async def test_deploy_bundle_local_charm_series_manifest(): |
181 | 186 | assert model.units['test1/0'].workload_status == 'active' |
182 | 187 |
|
183 | 188 |
|
| 189 | +@base.bootstrapped |
| 190 | +@pytest.mark.bundle |
| 191 | +async def test_deploy_bundle_with_pinned_charm_revision(): |
| 192 | + bundle_dir = INTEGRATION_TEST_DIR / 'bundle-with-charm-revision.yaml' |
| 193 | + bundle_yaml_path = bundle_dir / 'bundle-include-file.yaml' |
| 194 | + # Revision of the hello-juju charm defined in the bundle yaml |
| 195 | + # We can also read the yaml to get the revision but wr're hard-coding it for now for simplicity |
| 196 | + pinned_revision = 8 |
| 197 | + |
| 198 | + async with base.CleanModel() as model: |
| 199 | + await model.deploy(str(bundle_yaml_path)) |
| 200 | + |
| 201 | + application: Application = model.applications.get('hello-juju', None) |
| 202 | + status: FullStatus = await model.get_status([application.name]) |
| 203 | + # the 'charm' field of application status should be of this format: |
| 204 | + # ch:amd64/{series}/{name}-{revision} |
| 205 | + assert f"{application.name}-{pinned_revision}" in status.applications[application.name]["charm"] |
| 206 | + |
| 207 | + |
184 | 208 | @base.bootstrapped |
185 | 209 | @pytest.mark.bundle |
186 | 210 | async def test_deploy_invalid_bundle(): |
|
0 commit comments