コード例 #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_argument_passing(self):
     with cli_utils.get_cli_environment_context(
             argv=["--with-sample-plugin", "--plugin-option", "value"]):
         self.assertEquals(self.plugin.cmdline_param, "value")
コード例 #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 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)
コード例 #10
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)
コード例 #11
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")
コード例 #12
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())
コード例 #13
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")
コード例 #14
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
コード例 #15
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)
コード例 #16
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"])