moo.core.tests.test_exceptions
Tests for exception classes in moo/core/exceptions.py.
- Section 1: Pure unit tests verifying that each exception type produces a
meaningful string message (no DB required).
- Section 2: Integration tests confirming that naturally-triggered exceptions
propagate through parse.interpret and are caught/formatted by tasks.parse_command.
- Section 3: Integration tests for exceptions raised directly by core framework
code: RecursiveError (Object.save), AmbiguousVerbError (Object.get_verb), and AccessError (Object.is_allowed).
Functions
AccessError is raised by is_allowed(fatal=True) when a deny rule fires. |
|
AccessError.__str__ identifies the accessor, action, and subject. |
|
tasks.parse_command catches AmbiguousObjectError and formats it as bold red. |
|
Parser raises AmbiguousObjectError when two objects share a name in scope. |
|
AmbiguousObjectError.__str__ includes the name and both candidates. |
|
AmbiguousVerbError is raised by Object.get_verb() when an object has multiple Verb rows with the same name defined directly on it. |
|
AmbiguousVerbError.__str__ includes the verb name and both candidates. |
|
tasks.parse_command catches NoSuchObjectError and formats it as bold red. |
|
NoSuchObjectError is a UserError subclass and str() contains the name. |
|
NoSuchObjectError is raised when verb code calls get_dobj() but no object by that name exists in scope. |
|
tasks.parse_command catches NoSuchPrepositionError and formats it as bold red. |
|
NoSuchPrepositionError is raised when verb code calls get_pobj_str() for a preposition that was not present in the command. |
|
NoSuchPrepositionError.__str__ returns the user-facing message. |
|
tasks.parse_command catches NoSuchPropertyError and formats it as bold red. |
|
NoSuchPropertyError is a UserError subclass and str() contains the name. |
|
NoSuchPropertyError is raised when verb code calls get_property() for a property that does not exist on this or any ancestor. |
|
NoSuchPropertyError with origin includes origin in str(). |
|
tasks.parse_command catches NoSuchVerbError and formats it as bold red. |
|
NoSuchVerbError is a UserError subclass; .data stores the verb name. |
|
NoSuchVerbError is raised by the parser when no object has a matching verb and the location has no huh verb to fall back to. |
|
|
With prefixes_mode=True, error output contains the [ERROR] tag. |
|
Without prefixes_mode set, error output does not contain [ERROR] tag. |
|
NoSuchVerbError sets exit_status=1. |
|
UserError raises exit_status=1. |
A successful command sets exit_status=0. |
|
tasks.parse_command catches QuotaError and formats it as bold red. |
|
|
QuotaError is raised by create() when the caller's quota is exhausted. |
QuotaError.__str__ returns the message. |
|
RecursiveError is raised by Object.save() when moving an object would create a containment loop (box contains inner, then box.location = inner). |
|
RecursiveError.__str__ returns the message. |
|
UsageError.__str__ returns the usage message. |
|
UserError.__str__ returns the message. |