Example #1
0
class TestSubcommandConfig(SubcommandTestHelper):
    """Jump subcommand test suite."""

    def setUp(self):
        """Setup test suite."""
        self.subcommand = CfgSubcommand()
        self.subcommand_str = "config"
        super(TestSubcommandConfig, self).setUp()

    def test_parse_config_set(self):
        """Test config set."""
        self.assert_subcommand_parsing(["config", "set", "test", "test2"], {
            "subcommand": "config",
            "action": "set",
            "key": "test",
            "value": "test2"})

    def test_parse_config_get(self):
        """Test config set."""
        self.assert_subcommand_parsing(["config", "get", "test"], {
            "subcommand": "config",
            "action": "get",
            "key": "test"})

    def test_exec_config_with_undefined_action(self):
        """Test exec config with undefined subcommand."""
        args = Mock()
        args.action = "yoda"
        self.subcommand.execute(args)

    def test_exec_config_with_set(self):
        """Test exec config with set subcommand."""
        args = Mock()
        args.action = "set"
        args.key = "logfile"
        args.value = "/tmp/yoda.log"
        self.subcommand.execute(args)
        self.assertEqual("/tmp/yoda.log", self.config["logfile"])

    def test_exec_config_with_set_workspaces(self):
        """Test exec config with set workspaces subcommand."""
        args = Mock()
        args.action = "set"
        args.key = "workspaces"
        args.value = False
        self.assertFalse(self.subcommand.execute(args))

    def test_exec_config_with_get(self):
        """Test exec config with get subcommand."""
        args = Mock()
        args.action = "get"
        args.key = "logfile"
        self.assertFalse(self.subcommand.execute(args))
Example #2
0
 def setUp(self):
     """Setup test suite."""
     self.subcommand = CfgSubcommand()
     self.subcommand_str = "config"
     super(TestSubcommandConfig, self).setUp()