def test_destroy_controller_full(self): self.version_cli.return_get_destroy_controller_args = ["sub"] cli = CLI(self.exe, self.version_cli) cli.destroy_controller("spam", True) self.assertEqual(self.calls, [ ("get_destroy_controller_args", ("spam", True), {}), ("run", ("sub", ), {}), ])
def test_destroy_controller_minimal(self): self.version_cli.return_get_destroy_controller_args = ["sub"] cli = CLI(self.exe, self.version_cli) cli.destroy_controller() self.assertEqual(self.calls, [ ("get_destroy_controller_args", (None, False), {}), ("run", ("sub", ), {}), ])
def test_bootstrap_minimal(self): self.version_cli.return_get_bootstrap_args = ["sub"] cli = CLI(self.exe, self.version_cli) spec = BootstrapSpec("spam", "lxd") cli.bootstrap(spec) self.assertEqual(self.calls, [ ("get_bootstrap_args", (spec, None, None, False, False, False), {}), ("run", ("sub", ), {}), ])
def test_bootstrap_full(self): self.version_cli.return_get_bootstrap_args = ["sub"] cli = CLI(self.exe, self.version_cli) spec = BootstrapSpec("spam", "lxd") cli.bootstrap(spec, "0", "bootstrap.yaml", True, True, True) self.assertEqual(self.calls, [ ("get_bootstrap_args", (spec, "0", "bootstrap.yaml", True, True, True), {}), ("run", ("sub", ), {}), ])
def test_api_info_minimal(self): self.version_cli.return_get_api_info_args = ["sub"] self.exe.return_run_out = "<output>" expected = APIInfo(["host"], "admin", "pw") self.version_cli.return_parse_api_info = {"spam": expected._asdict()} cli = CLI(self.exe, self.version_cli) info = cli.api_info() self.assertEqual(info, {"spam": expected}) self.assertEqual(self.calls, [ ("get_api_info_args", (None, ), {}), ("run_out", ("sub", ), {}), ("parse_api_info", ("<output>", None), {}), ])
def test_api_info_minimal(self): filename, callfile = write_script(self.dirname, output=self.API_INFO_YAML) self.cli = CLI.from_version(filename, self.VERSION, self.dirname) infos = self.cli.api_info() self.assertEquals( infos, { None: APIInfo( ["10.235.227.251:17070"], "admin", "0f154812dd1c02973623c887b2565ea3", ), "controller": APIInfo( ["10.235.227.251:17070"], "admin", "0f154812dd1c02973623c887b2565ea3", "d3a5befc-c392-4722-85fc-631531e74a09", ), "default": APIInfo( ["10.235.227.251:17070"], "admin", "0f154812dd1c02973623c887b2565ea3", "b93f17f2-ad56-456d-8051-06e9f7ba46ec", ), }) self.assert_called("show-controller --show-password --format=yaml", callfile)
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_api_info_minimal(self): filename, callfile = write_script(self.dirname, output=self.API_INFO_JSON) self.cli = CLI.from_version(filename, self.VERSION, self.dirname) infos = self.cli.api_info() self.assertEquals( infos, { None: APIInfo( ["10.235.227.251:17070"], "admin", "0f154812dd1c02973623c887b2565ea3", ), "controller": APIInfo( ["10.235.227.251:17070"], "admin", "0f154812dd1c02973623c887b2565ea3", "d3a5befc-c392-4722-85fc-631531e74a09", ), }) self.assert_called("api-info --password --refresh --format=json", callfile)
def setUp(self): super(CLIJuju2Tests, self).setUp() self.dirname = tempfile.mkdtemp(prefix="txjuju-test-") filename, self.callfile = write_script(self.dirname) self.cli = CLI.from_version(filename, self.VERSION, self.dirname)
def test_missing_executable(self): version_cli = object() with self.assertRaises(ValueError): CLI(None, version_cli)
def test_from_version_unsupported_version(self): with self.assertRaises(ValueError): CLI.from_version("juju", "1.25.6", None) with self.assertRaises(ValueError): CLI.from_version("juju", "1.25.6", "")
def test_from_version_missing_version(self): with self.assertRaises(ValueError): CLI.from_version("juju", None, "/tmp") with self.assertRaises(ValueError): CLI.from_version("juju", "", "/tmp")
def test_from_version_missing_filename(self): with self.assertRaises(ValueError): CLI.from_version(None, "1.25.6", "/tmp") with self.assertRaises(ValueError): CLI.from_version("", "1.25.6", "/tmp")
def test_from_version_executable_not_found(self): filename = self._resolve_executable("does-not-exist") with self.assertRaises(_utils.ExecutableNotFoundError): CLI.from_version(filename, "1.25.6", "/tmp")