diff --git a/tests/integration/test_model.py b/tests/integration/test_model.py index b9147db8..6a181bbd 100644 --- a/tests/integration/test_model.py +++ b/tests/integration/test_model.py @@ -14,7 +14,7 @@ import pylxd import pytest -from juju import jasyncio +from juju import jasyncio, url from juju.client.client import ApplicationFacade, ConfigValue from juju.errors import JujuError, JujuUnitError, JujuConnectionError from juju.model import Model, ModelObserver @@ -88,6 +88,38 @@ async def test_deploy_bundle_local_resource_relative_path(event_loop): timeout=60 * 4) +@base.bootstrapped +@pytest.mark.asyncio +async def test_deploy_by_revision(event_loop): + async with base.CleanModel() as model: + app = await model.deploy('juju-qa-test', + application_name='test', + channel='2.0/stable', + revision=22,) + + assert url.URL.parse(app.charm_url).revision == 22 + + +@base.bootstrapped +@pytest.mark.asyncio +async def test_deploy_by_revision_validate_flags(event_loop): + # Make sure we fail gracefully when invalid --revision/--channel + # flags are used + + async with base.CleanModel() as model: + # For charms --revision requires --channel + with pytest.raises(JujuError): + await model.deploy('juju-qa-test', + # channel='2.0/stable', + revision=22) + + # For bundles, --revision and --channel are mutually exclusive + with pytest.raises(JujuError): + await model.deploy('ch:canonical-livepatch-onprem', + channel='latest/stable', + revision=4) + + @base.bootstrapped @pytest.mark.asyncio async def test_deploy_local_bundle_include_file(event_loop):