def test_not_if_already_local(self): meta = CharmMeta.from_yaml("series: [kubernetes]") with patch.dict( os.environ, {"JUJU_VERSION": "2.8"}), tempfile.NamedTemporaryFile() as fd: self.assertFalse( _should_use_controller_storage(Path(fd.name), meta)) self.assertLogged('Using local storage: {} already exists'.format( fd.name))
def test_not_if_not_in_k8s(self): meta = CharmMeta.from_yaml("series: [ecs]") with patch.dict(os.environ, {"JUJU_VERSION": "2.8"}): self.assertFalse(_should_use_controller_storage(Path("/xyzzy"), meta)) self.assertLogged('Using local storage: not a kubernetes charm')
def test_fallback_to_current_juju_version__new_enough(self): meta = CharmMeta.from_yaml("series: [kubernetes]") with patch.dict(os.environ, {"JUJU_VERSION": "2.8"}): self.assertTrue(_should_use_controller_storage(Path("/xyzzy"), meta)) self.assertLogged('Using controller storage: JUJU_VERSION=2.8.0')
def test_fallback_to_current_juju_version__too_old(self): meta = CharmMeta.from_yaml("series: [kubernetes]") with patch.dict(os.environ, {"JUJU_VERSION": "1.0"}): self.assertFalse(_should_use_controller_storage(Path("/xyzzy"), meta)) self.assertLogged('Using local storage: JUJU_VERSION=1.0.0')