def test_deactivation(self): plugins.manager.activate(self.plugin) with cli_utils.get_cli_environment_context( argv=["--without-sample-plugin"]): self.assertNotIn(self.plugin.get_name(), plugins.manager.get_active_plugins()) self.assertIn(self.plugin.get_name(), plugins.manager.get_active_plugins())
def test_config_assign_wrong_path_restores_config(self): "Given a bad override, the get_parsed_config_args_context() should leave the configuration untouched" with self.assertRaises(SystemExit) as caught: with cli_utils.get_cli_environment_context(argv=["-o", "string_value=bla", "-o", "int_value=hello"], config=self.config): pass self.assertNotEquals(caught.exception.code, 0) self.assertEquals(self.config.root.int_value, 0) self.assertEquals(self.config.root.string_value, "")
def test_config_assign_wrong_path_restores_config(self): "Given a bad override, the get_parsed_config_args_context() should leave the configuration untouched" with self.assertRaises(SystemExit) as caught: with cli_utils.get_cli_environment_context( argv=["-o", "string_value=bla", "-o", "int_value=hello"], config=self.config): pass self.assertNotEquals(caught.exception.code, 0) self.assertEquals(self.config.root.int_value, 0) self.assertEquals(self.config.root.string_value, "")
def test_deactivation(self): plugins.manager.activate(self.plugin) with cli_utils.get_cli_environment_context(argv=["--without-sample-plugin"]): self.assertNotIn(self.plugin.get_name(), plugins.manager.get_active_plugins()) self.assertIn(self.plugin.get_name(), plugins.manager.get_active_plugins())
def test_activation(self): with cli_utils.get_cli_environment_context(argv=["--with-sample-plugin"]): self.assertIn(self.plugin.get_name(), plugins.manager.get_active_plugins(), "plugin was not activated")
def test_arguments_are_not_parsed_if_not_activated(self): args = ["--start-session-option", "2"] with self.assertRaises(SystemExit): with cli_utils.get_cli_environment_context(argv=args): pass
def test_config_assign_flag(self): with cli_utils.get_cli_environment_context(argv=["-o", "string_value=hello", "-o", "int_value=666"], config=self.config): self.assertEquals(self.config.root.string_value, "hello") self.assertEquals(self.config.root.int_value, 666)
def test_config_on_flag(self): with cli_utils.get_cli_environment_context(argv=["--flag2"], config=self.config): self.assertTrue(self.config["b"]["b1"]["flag2"]) self.assertFalse(self.config["b"]["b1"]["flag2"])
def _cli(self, argv): return cli_utils.get_cli_environment_context(argv=argv, config=self.config)
def test_activation(self): with cli_utils.get_cli_environment_context( argv=["--with-sample-plugin"]): self.assertIn(self.plugin.get_name(), plugins.manager.get_active_plugins(), "plugin was not activated")
def test_config_assign_flag(self): with cli_utils.get_cli_environment_context( argv=["-o", "string_value=hello", "-o", "int_value=666"], config=self.config): self.assertEquals(self.config.root.string_value, "hello") self.assertEquals(self.config.root.int_value, 666)
def test_help_shows_available_plugins(self): with self.assertRaises(SystemExit): with cli_utils.get_cli_environment_context(argv=["-h"]): pass output = self.stdout.getvalue() self.assertIn("--with-sample-plugin", output)
def test_argument_passing(self): with cli_utils.get_cli_environment_context(argv=["--with-sample-plugin", "--plugin-option", "value"]): self.assertEquals(self.plugin.cmdline_param, "value")
def test_argument_passing(self): with cli_utils.get_cli_environment_context( argv=["--with-sample-plugin", "--plugin-option", "value"]): self.assertEquals(self.plugin.cmdline_param, "value")