def test_has_default_commands(config): config1 = CommandConfig("command1") config1.default() config.add_command_config(config1) app = ConsoleApplication(config) assert app.has_default_commands()
def test_has_no_named_commands(config): config1 = CommandConfig("command1") config1.anonymous() config.add_command_config(config1) app = ConsoleApplication(config) assert not app.has_named_commands()
def test_get_commands_excludes_disabled_commands(config): enabled = CommandConfig("command1").enable() disabled = CommandConfig("command2").disable() config.add_command_config(enabled) config.add_command_config(disabled) app = ConsoleApplication(config) assert len(app.commands) == 1 assert app.commands.get("command1").name == enabled.name
def test_get_commands(config): config1 = CommandConfig("command1") config2 = CommandConfig("command2") config.add_command_config(config1) config.add_command_config(config2) app = ConsoleApplication(config) assert len(app.commands) == 2 assert app.commands.get("command1").name == config1.name assert app.commands.get("command2").name == config2.name
def test_has_command(config): config1 = CommandConfig("command1") config.add_command_config(config1) app = ConsoleApplication(config) assert app.has_command(config1.name)
def test_get_command(config): config1 = CommandConfig("command1") config.add_command_config(config1) app = ConsoleApplication(config) command = app.get_command("command1") assert command.name == config1.name
def test_get_default_commands(config): config1 = CommandConfig("command1") config2 = CommandConfig("command2") config3 = CommandConfig("command3") config2.default() config3.default() config.add_command_config(config1) config.add_command_config(config2) config.add_command_config(config3) app = ConsoleApplication(config) assert len(app.default_commands) == 2
def test_fails_if_duplicate_command_name(config): config.add_command_config(CommandConfig("command")) config.add_command_config(CommandConfig("command")) with pytest.raises(CannotAddCommandException): ConsoleApplication(config)