def test_missing_version_cli(self): """ get_executable() fails if version_cli is None. """ filename = self._write_executable("spam") with self.assertRaises(ValueError): get_executable(filename, None, "/tmp")
def test_missing_cfgdir(self): """ get_executable() fails if cfgdir is None or empty. """ with self.assertRaises(ValueError): get_executable("spam", self.CLI, None) with self.assertRaises(ValueError): get_executable("spam", self.CLI, "")
def test_missing_filename(self): """ get_executable() fails if filename is None or empty. """ with self.assertRaises(ValueError): get_executable("", self.CLI, "/tmp") with self.assertRaises(ValueError): get_executable(None, self.CLI, "/tmp")
def test_missing_version_cli(self): class cli(object): CFGDIR_ENVVAR = "JUJU_HOME" exe = get_executable("juju", cli, "/tmp") with self.assertRaises(ValueError): CLI(exe, None)
def test_minimal(self): """ get_executable() works when given minimal args. """ exe = get_executable("spam", self.CLI, "/tmp") self.assertEqual(exe.filename, "spam") self.assertEqual(exe.envvars["JUJU_HOME"], "/tmp") self.assertNotEqual(exe.envvars, {"JUJU_HOME": "/tmp"})
def test_relative_filename(self): """ get_executable() searches for the executable if the provided filename is relative. """ filename = self._write_executable("spam") os.environ["PATH"] = self.dirname exe = get_executable("spam", self.CLI, "/tmp") self.assertEqual(exe.filename, filename)
def test_full(self): """ get_executable() works when all args are provided. """ exe = get_executable("spam", self.CLI, "/tmp", {"SPAM": "eggs"}) self.assertEqual( exe, _utils.Executable("spam", { "SPAM": "eggs", "JUJU_HOME": "/tmp" }))
def test_missing_version_cli(self): """ get_executable() fails if version_cli is None. """ with self.assertRaises(ValueError): get_executable("spam", None, "/tmp")