def resolve(vague_name, repository_path, default_series): """Get a Charm and associated identifying information :param str vague_name: a lazily specified charm name, suitable for use with :meth:`CharmURL.infer` :param repository_path: where on the local filesystem to find a repository (only currently meaningful when `charm_name` is specified with `"local:"`) :type repository_path: str or None :param str default_series: the Ubuntu series to insert when `charm_name` is inadequately specified. :return: a tuple of a :class:`juju.charm.url.CharmURL` and a :class:`juju.charm.base.CharmBase` subclass, which together contain both the charm's data and all information necessary to specify its source. """ url = CharmURL.infer(vague_name, default_series) if url.collection.schema == "local": repo = LocalCharmRepository(repository_path) elif url.collection.schema == "cs": repo = RemoteCharmRepository("https://store.juju.ubuntu.com") return repo, url
def test_deploy_upgrade_remote(self): """The upgrade option is invalid with a remote charm.""" repo = self.mocker.mock(RemoteCharmRepository) repo.type self.mocker.result("store") resolve = self.mocker.replace("juju.control.deploy.resolve") resolve("cs:sample", None, "series") self.mocker.result((repo, CharmURL.infer("cs:sample", "series"))) repo.find(MATCH(lambda x: isinstance(x, CharmURL))) self.mocker.result(CharmDirectory(self.sample_dir1)) self.mocker.replay() environment = self.config.get("firstenv") error = yield self.assertFailure(deploy.deploy( self.config, environment, None, "cs:sample", "myblog", logging.getLogger("deploy"), [], upgrade=True), CharmError) self.assertIn("Only local directory charms can be upgraded on deploy", str(error))
def assert_infer(self, string, schema, user, series, name, rev): url = CharmURL.infer(string, "default") self.assert_url(url, schema, user, series, name, rev)