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:
Eeshan Garg
2018-12-22 19:43:57 -03:30
committed by Tim Abbott
parent a378407c57
commit 8a02e177e3
7 changed files with 103 additions and 2 deletions

View File

@@ -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)