tests: Implement mock weechat module and add some color tests.

This commit is contained in:
poljar (Damir Jelić) 2018-03-02 22:58:43 +01:00
parent 404f785f21
commit fc6a6e9da9
5 changed files with 165 additions and 35 deletions

26
tests/color_test.py Normal file
View file

@ -0,0 +1,26 @@
import webcolors
from hypothesis import given
from hypothesis.strategies import sampled_from
from matrix.colors import (Formatted, color_html_to_weechat,
color_weechat_to_html)
html_prism = ("<font color=maroon>T</font><font color=red>e</font><font "
"color=olive>s</font><font color=yellow>t</font>")
weechat_prism = (
u"\x1b[038;5;1mT\x1b[039m\x1b[038;5;9me\x1b[039m\x1b[038;5;3ms\x1b[039m\x1b[038;5;11mt\x1b[039m"
)
first_16_html_colors = list(webcolors.HTML4_HEX_TO_NAMES.values())
def test_prism():
formatted = Formatted.from_html(html_prism)
assert formatted.to_weechat() == weechat_prism
@given(sampled_from(first_16_html_colors))
def test_color_conversion(color_name):
assert color_weechat_to_html(
color_html_to_weechat(color_name)) == color_name