mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
Adding more test cases, fixed some duplicated formatter names
This commit is contained in:
parent
45030b6731
commit
bd5916e042
|
@ -48,7 +48,7 @@ def compact_cargo_createtable(ctx: Context, change: dict):
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
# cargo/recreatetable
|
# cargo/recreatetable - Recreating a Cargo table
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="cargo/recreatetable")
|
@formatter.embed(event="cargo/recreatetable")
|
||||||
|
@ -71,7 +71,7 @@ def compact_cargo_recreatetable(ctx: Context, change: dict):
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
# cargo/replacetable
|
# cargo/replacetable - Replacing a Cargo table
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="cargo/replacetable")
|
@formatter.embed(event="cargo/replacetable")
|
||||||
|
@ -84,7 +84,7 @@ def embed_cargo_replacetable(ctx: Context, change: dict):
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="cargo/recreatetable")
|
@formatter.compact(event="cargo/replacetable")
|
||||||
def compact_cargo_replacetable(ctx: Context, change: dict):
|
def compact_cargo_replacetable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
table = re.search(r"\[(.*?)]\(<(.*?)>\)", ctx.client.parse_links(change["logparams"]["0"]))
|
||||||
|
@ -94,7 +94,7 @@ def compact_cargo_replacetable(ctx: Context, change: dict):
|
||||||
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
return DiscordMessage(ctx.message_type, ctx.event, ctx.webhook_url, content=content)
|
||||||
|
|
||||||
|
|
||||||
# cargo/deletetable
|
# cargo/deletetable - Deleting a table in Cargo
|
||||||
|
|
||||||
|
|
||||||
@formatter.embed(event="cargo/deletetable")
|
@formatter.embed(event="cargo/deletetable")
|
||||||
|
@ -106,7 +106,7 @@ def embed_cargo_deletetable(ctx: Context, change: dict):
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="cargo/recreatetable")
|
@formatter.compact(event="cargo/deletetable")
|
||||||
def compact_cargo_deletetable(ctx: Context, change: dict):
|
def compact_cargo_deletetable(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
content = _("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author,
|
content = _("[{author}]({author_url}) deleted the Cargo table \"{table}\"").format(author=author,
|
||||||
|
|
|
@ -195,7 +195,7 @@ def embed_managewiki_unlock(ctx: Context, change: dict):
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
@formatter.compact(event="managewiki/undelete")
|
@formatter.compact(event="managewiki/unlock")
|
||||||
def compact_managewiki_unlock(ctx: Context, change: dict):
|
def compact_managewiki_unlock(ctx: Context, change: dict):
|
||||||
author, author_url = compact_author(ctx, change)
|
author, author_url = compact_author(ctx, change)
|
||||||
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
parsed_comment = "" if ctx.parsedcomment is None else " *(" + ctx.parsedcomment + ")*"
|
||||||
|
|
|
@ -14,12 +14,21 @@
|
||||||
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
# along with RcGcDw. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from unittest import TestCase, main
|
from unittest import TestCase, main
|
||||||
from src.api.util import sanitize_to_url
|
from src.api.util import sanitize_to_url, sanitize_to_markdown, clean_link
|
||||||
|
|
||||||
|
|
||||||
class Test(TestCase):
|
class Test(TestCase):
|
||||||
def test_sanitize_to_url(self):
|
def test_sanitize_to_url(self):
|
||||||
self.assertEqual(sanitize_to_url("Breaking rcgcdw . \ / : ? = ) & - ~ this is a test)"), "Breaking_rcgcdw_._%5C_/_:_%3F_%3D_%29_%26_-_~_this_is_a_test%29")
|
self.assertEqual(sanitize_to_url("Breaking rcgcdw . \ / : ? = ) & - ~ this is a test)"),
|
||||||
|
"Breaking_rcgcdw_._%5C_/_:_%3F_%3D_%29_%26_-_~_this_is_a_test%29")
|
||||||
|
|
||||||
|
def test_sanitize_to_markdown(self):
|
||||||
|
self.assertEqual(sanitize_to_markdown(
|
||||||
|
" This @MarkusRost [] is a **Markdown** te\"'''st __wow__ (I'm a link)[https://google.com/____]^^ ` nice {} comment\\\\foa*&&V^%A(!#)@!@I$Jfkasnfgamc,ajf ah wtf#####;h,a "),
|
||||||
|
" This \\@MarkusRost [] is a \\*\\*Markdown\\*\\* te\"\'\'\'st \\_\\_wow\\_\\_ (I\'m a link)[https\\:/\\/google.com/\\_\\_\\_\\_]^^ \\` nice \\{\\} comment\\\\\\\\foa\\*&&V^%A(!#)\\@!\\@I$Jfkasnfgamc,ajf ah wtf#####;h,a ")
|
||||||
|
|
||||||
|
def test_clean_link(self):
|
||||||
|
self.assertEqual(clean_link("https://example.com"), "<https://example.com>")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue