diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2019-04-02 09:58:56 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-04-08 15:11:57 +0200 |
commit | b459586d96ec1f765d7aed86538b8d8576977f6c (patch) | |
tree | 63488459b22c11b83589b9cfe562f58b4c701b57 /_pytest/test_linkifytext.py | |
parent | 82147d2d2a47927528e993816ee9393a4aa15b83 (diff) | |
download | wee-slack-b459586d96ec1f765d7aed86538b8d8576977f6c.tar.gz |
Cleanup tests and make them compatible with python 3
This mainly adds team, channel_general and user_alice as fixtures, so we
can use those directly instead of picking arbitrary ones from the lists.
It also adds assertions to some tests which where missing it.
Diffstat (limited to '_pytest/test_linkifytext.py')
-rw-r--r-- | _pytest/test_linkifytext.py | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/_pytest/test_linkifytext.py b/_pytest/test_linkifytext.py index a4db120..a31fa6d 100644 --- a/_pytest/test_linkifytext.py +++ b/_pytest/test_linkifytext.py @@ -2,79 +2,55 @@ from __future__ import print_function, unicode_literals -from wee_slack import linkify_text - - -#def test_linkifytext(): -# linkify_text('@ryan') - -# assert False +import re +from wee_slack import linkify_text -def test_linkifytext_does_partial_html_entity_encoding(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] +def test_linkifytext_does_partial_html_entity_encoding(team): text = linkify_text('& < > \' "', team) assert text == '& < > \' "' -def test_linkifytext_names_with_paranthesis(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - +def test_linkifytext_names_with_paranthesis(team): text = linkify_text('@JohnDoe(jdoe): my test message', team) assert text == '@JohnDoe(jdoe): my test message' -def test_linkifytext_names_with_accents(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - +def test_linkifytext_names_with_accents(team): text = linkify_text('@ÁrvíztűrőTükörfúrógép(atukorfurogep): my test message', team) assert text == '@ÁrvíztűrőTükörfúrógép(atukorfurogep): my test message' -def test_linkifytext_formatting_characters(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - +def test_linkifytext_formatting_characters(team): text = linkify_text('\x02\x1Dmy test message\x1D\x02', team) assert text == '*_my test message_*' -def test_linkifytext_with_many_paranthesis(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - +def test_linkifytext_with_many_paranthesis(team): text = linkify_text('@k(o(v)a)())s: my(( test) message', team) assert text == '@k(o(v)a)())s: my(( test) message' -def test_linkifytext_names_with_apostrophe(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - +def test_linkifytext_names_with_apostrophe(team): text = linkify_text('@O\'Connor: my test message', team) assert text == '@O\'Connor: my test message' -def test_linkifytext_names_with_subgroup_notification(realish_eventrouter): - subteam_id = "TGX0ALBK3" - handle = "test" - team = realish_eventrouter.teams.values()[0] - channel = team.channels.values()[0] +def test_linkifytext_names_with_subgroup_notification(team): + subteam = team.subteams['TGX0ALBK3'] + message = 'This is a message for a subteam' + text = linkify_text('@{}: {}'.format(subteam.handle, message), team) - message = 'This is a message for the test team' - text = linkify_text('@test: {}'.format(message), team) - - assert text == '<!subteam^{}|@{}>: {}'.format(subteam_id, handle, message) - -def test_linkifytext_at_channel(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] + assert text == '<!subteam^{}|@{}>: {}'.format(subteam.identifier, subteam.handle, message) +def test_linkifytext_at_channel(team): text = linkify_text('@channel: my test message', team) assert text == '<!channel>: my test message' -def test_linkifytext_channel(realish_eventrouter): - team = realish_eventrouter.teams.values()[0] - channel = team.channels.values()[0] - - text = linkify_text('#{}: my test message'.format(channel.name), team) +def test_linkifytext_channel(team, channel_general): + channel_name = re.sub(r'^[#&]', '', channel_general.name) + text = linkify_text('#{}: my test message'.format(channel_name), team) - assert text == '<#{}|{}>: my test message'.format(channel.id, channel.name) + assert text == '<#{}|{}>: my test message'.format(channel_general.id, channel_name) |