示例#1
0
 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())
示例#2
0
 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, "")
示例#3
0
 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, "")
示例#4
0
 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())
示例#5
0
 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")
示例#6
0
 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
示例#7
0
 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)
示例#8
0
 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"])
示例#9
0
 def _cli(self, argv):
     return cli_utils.get_cli_environment_context(argv=argv, config=self.config)
示例#10
0
 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")
示例#11
0
 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
示例#12
0
 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)
示例#13
0
 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"])
示例#14
0
 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)
示例#15
0
 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")
示例#16
0
 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")
示例#17
0
 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)
示例#18
0
 def _cli(self, argv):
     return cli_utils.get_cli_environment_context(argv=argv,
                                                  config=self.config)