mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
bugdown: Trigger test failure for invalid Markdown include statements.
This commit adds a custom Markdown include extension which is identical to the original except when a macro file can't be found, it raises a custom JsonableError exception, which we can catch and then trigger an appropriate test failure. Fixes: #10947
This commit is contained in:
@@ -41,6 +41,7 @@ class ErrorCode(AbstractEnum):
|
||||
CSRF_FAILED = ()
|
||||
INVITATION_FAILED = ()
|
||||
INVALID_ZULIP_SERVER = ()
|
||||
INVALID_MARKDOWN_INCLUDE_STATEMENT = ()
|
||||
REQUEST_CONFUSING_VAR = ()
|
||||
|
||||
class JsonableError(Exception):
|
||||
@@ -152,6 +153,17 @@ class CannotDeactivateLastUserError(JsonableError):
|
||||
def msg_format() -> str:
|
||||
return _("Cannot deactivate the only {entity}.")
|
||||
|
||||
class InvalidMarkdownIncludeStatement(JsonableError):
|
||||
code = ErrorCode.INVALID_MARKDOWN_INCLUDE_STATEMENT
|
||||
data_fields = ['include_statement']
|
||||
|
||||
def __init__(self, include_statement: str) -> None:
|
||||
self.include_statement = include_statement
|
||||
|
||||
@staticmethod
|
||||
def msg_format() -> str:
|
||||
return _("Invalid markdown include statement: {include_statement}")
|
||||
|
||||
class RateLimited(PermissionDenied):
|
||||
def __init__(self, msg: str="") -> None:
|
||||
super().__init__(msg)
|
||||
|
||||
Reference in New Issue
Block a user