def test_subcommand_incorrect(self): parser = ArgumentParser() config = CloudCleanerConfig(parser=parser, args=["notfound"]) config.set_args(["notfound"]) config.add_subparser("found") # ArgumentError raises SystemExit internally, apparently with self.assertRaises(SystemExit): config.parse_args()
def test_set_args(self): parser = ArgumentParser() config = CloudCleanerConfig(parser=parser, args=[]) config.add_subparser("item") config.set_args(["--os-auth-url", "http://no.com", "item"]) config.parse_args() self.assertEqual("item", config.get_resource()) config.warning("Dummy warning") log = getLogger("cloud_cleaner") self.assertEqual(log.getEffectiveLevel(), WARNING) self.assertIsNone(config.get_arg("no_arg"))
def test_init_with_name(self): # pylint: disable=no-self-use parser = ArgumentParser() config = CloudCleanerConfig(parser=parser, args=[]) config.add_subparser = Mock() server = Server() server.register(config) config.add_subparser.assert_called_once_with(Server.type_name)
def test_resource_type(self): # pylint: disable=no-self-use parser = ArgumentParser() config = CloudCleanerConfig( parser=parser, args=["--os-auth-url", "http://no.com", "fip"]) config.add_subparser = Mock() fip = Fip() fip.register(config) config.add_subparser.assert_called_once_with(Fip.type_name)