Fixed addcommand conflict messaging for non-custom commands.
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 2m57s
CI / Tests (Python 3.13) (push) Successful in 2m56s
CI / Tests (Python 3.14) (push) Successful in 2m49s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 4s

This commit is contained in:
2026-05-11 12:05:36 -04:00
parent 06b4a0bb9c
commit 62c5cd0ba5
3 changed files with 60 additions and 2 deletions
@@ -632,11 +632,35 @@ class TestManager:
self,
manager: CommandManager,
) -> None:
"""Create_command raises CommandAlreadyExistsError on conflict."""
"""Create_command raises CommandAlreadyExistsError for custom conflicts."""
await manager.create_command("greet", "Hi")
with pytest.raises(CommandAlreadyExistsError) as exc_info:
await manager.create_command("greet", "Info")
assert exc_info.value.name == "greet"
async def test_create_rejects_not_custom_conflict(
self,
manager: CommandManager,
) -> None:
"""Create_command raises NotCustomCommandError for non-custom conflicts."""
with pytest.raises(NotCustomCommandError) as exc_info:
await manager.create_command("about", "Info")
assert exc_info.value.name == "about"
async def test_create_rejects_inactive_conflict(
self,
manager: CommandManager,
command_dispatcher: CommandDispatcher,
module_context: ModuleContext,
) -> None:
"""Create_command raises InactiveCommandError for inactive custom conflicts."""
await manager.create_command("greet", "Hi")
module_context.commands.unregister("greet")
_register_foreign_command(command_dispatcher, "greet")
with pytest.raises(InactiveCommandError) as exc_info:
await manager.create_command("greet", "Info")
assert exc_info.value.name == "greet"
async def test_create_rollback_on_db_failure(
self,
manager: CommandManager,
@@ -1178,6 +1202,20 @@ class TestAddCommand:
"Command !greet already exists. Use '!editcommand' to modify it."
)
async def test_not_custom_conflict(
self,
event_dispatcher: EventDispatcher,
owncast_client: RecordingOwncastClient,
) -> None:
"""!addcommand with a non-custom command name reports the right error."""
user = make_user(is_moderator=True)
event = make_chat_event(raw_body="!addcommand !about Hacked", user=user)
await event_dispatcher.dispatch(EventType.CHAT, event)
assert _send_bodies(owncast_client)[0] == (
"That command is not a custom command and cannot be modified."
)
@pytest.mark.usefixtures("module_lifecycle")
class TestEditCommand:
@@ -1897,6 +1935,7 @@ class TestInactiveCommandRejection:
"raw_body",
[
pytest.param("!editcommand !greet New!", id="editcommand"),
pytest.param("!addcommand !greet New!", id="addcommand"),
pytest.param("!commandmodonly !greet on", id="commandmodonly"),
pytest.param("!resetcommand !greet", id="resetcommand"),
pytest.param("!commandcooldown !greet 10", id="commandcooldown"),