def test_admin_subcommand_execution(self): """ Setup an admin subcommand, and verify that's it invoked. """ self.setup_cli_reactor() self.setup_exit(0) self.patch(control, "ADMIN_SUBCOMMANDS", [DummySubcommand]) setup_logging_mock = self.mocker.mock(setup_logging) setup_parser_mock = self.mocker.proxy(setup_parser) self.patch(control, "setup_logging", setup_logging_mock) self.patch(control, "setup_parser", setup_parser_mock) command_mock = self.mocker.proxy(DummySubcommand.command) self.patch(DummySubcommand, "command", command_mock) setup_parser_mock( subcommands=ANY, prog="juju-admin", description="juju cloud orchestration internal tools") self.mocker.passthrough() setup_logging_mock(ANY) command_mock(ANY) self.mocker.passthrough() self.mocker.replay() admin(["dummy"])
def test_initialize(self): """The admin cli dispatches the initialize method with arguments.""" client = self.mocker.patch(ZookeeperClient) hierarchy = self.mocker.patch(StateHierarchy) self.setup_cli_reactor() client.connect() self.mocker.result(succeed(client)) hierarchy.initialize() self.mocker.result(succeed(True)) client.close() self.capture_stream("stderr") self.setup_exit(0) self.mocker.replay() constraints_data = b64encode(safe_dump({"ubuntu-series": "foo", "provider-type": "bar"})) admin( [ "initialize", "--instance-id", "foobar", "--admin-identity", "admin:genie", "--constraints-data", constraints_data, "--provider-type", "dummy", ] )
def test_initialize(self): """The admin cli dispatches the initialize method with arguments.""" client = self.mocker.patch(ZookeeperClient) hierarchy = self.mocker.patch(StateHierarchy) self.setup_cli_reactor() client.connect() self.mocker.result(succeed(client)) hierarchy.initialize() self.mocker.result(succeed(True)) client.close() self.capture_stream('stderr') self.setup_exit(0) self.mocker.replay() admin([ "initialize", "--instance-id", "foobar", "--admin-identity", "admin:genie", "--provider-type", "dummy" ])
def test_initialize(self): """The admin cli dispatches the initialize method with arguments.""" client = self.mocker.patch(ZookeeperClient) hierarchy = self.mocker.patch(StateHierarchy) self.setup_cli_reactor() client.connect() self.mocker.result(succeed(client)) hierarchy.initialize() self.mocker.result(succeed(True)) client.close() self.capture_stream('stderr') self.setup_exit(0) self.mocker.replay() admin(["initialize", "--instance-id", "foobar", "--admin-identity", "admin:genie", "--provider-type", "dummy"])
def test_bad_constraints_data(self): """Test that failing to unpack --constraints-data aborts initialize""" client = self.mocker.patch(ZookeeperClient) self.setup_cli_reactor() client.connect() self.mocker.result(succeed(client)) self.capture_stream("stderr") self.setup_exit(1) self.mocker.replay() admin( [ "initialize", "--instance-id", "foobar", "--admin-identity", "admin:genie", "--constraints-data", "zaphod's just this guy, you know?", "--provider-type", "dummy", ] )