summaryrefslogtreecommitdiff
path: root/test/test_ui/test_funcs.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-09 22:58:17 +0200
committermathieui <mathieui@mathieui.net>2020-05-09 22:58:17 +0200
commitf68fa1da5e2cccd396ee03eec12359ff905b7bc6 (patch)
tree135acd2d1ed2a4e7e382d9bd4f574ef6f54a023e /test/test_ui/test_funcs.py
parentd22b4b8c218cbbaee62002d751bd69bfe1d1deab (diff)
parentca85411af06c59ec63b9cc2c0b2b2f398da79e8a (diff)
downloadpoezio-f68fa1da5e2cccd396ee03eec12359ff905b7bc6.tar.gz
poezio-f68fa1da5e2cccd396ee03eec12359ff905b7bc6.tar.bz2
poezio-f68fa1da5e2cccd396ee03eec12359ff905b7bc6.tar.xz
poezio-f68fa1da5e2cccd396ee03eec12359ff905b7bc6.zip
Merge branch 'split-message-rendering' into 'master'
split message rendering See merge request poezio/poezio!48
Diffstat (limited to 'test/test_ui/test_funcs.py')
-rw-r--r--test/test_ui/test_funcs.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/test_ui/test_funcs.py b/test/test_ui/test_funcs.py
new file mode 100644
index 00000000..0e61549c
--- /dev/null
+++ b/test/test_ui/test_funcs.py
@@ -0,0 +1,46 @@
+from poezio.ui.funcs import (
+ find_first_format_char,
+ parse_attrs,
+ truncate_nick,
+)
+
+
+def test_find_char_not_present():
+ assert find_first_format_char("toto") == -1
+
+
+def test_find_char():
+ assert find_first_format_char('a \x1A 1') == 2
+
+
+def test_truncate_nick():
+ assert truncate_nick("toto") == "toto"
+
+
+def test_truncate_nick_wrong_size():
+ assert truncate_nick("toto", -10) == "t…"
+
+
+def test_truncate_nick_too_long():
+ nick = "012345678901234567"
+ assert truncate_nick(nick) == nick[:10] + "…"
+
+
+def test_truncate_nick_no_nick():
+ assert truncate_nick('') == ''
+
+
+def test_parse_attrs():
+ text = "\x19o\x19u\x19b\x19i\x191}\x19o\x194}"
+ assert parse_attrs(text) == ['4}']
+
+
+def test_parse_attrs_broken_char():
+ text = "coucou\x19"
+ assert parse_attrs(text) == []
+
+
+def test_parse_attrs_previous():
+ text = "coucou"
+ previous = ['u']
+ assert parse_attrs(text, previous=previous) == previous