aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_linkifytext.py
blob: fea6ab85fe59f7c690d51f3a9f4af108c949a409 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from wee_slack import linkify_text


#def test_linkifytext():
#    linkify_text('@ryan')

#    assert False


def test_linkifytext_does_partial_html_entity_encoding(realish_eventrouter):
    team = realish_eventrouter.teams.values()[0]

    text = linkify_text('& < > \' "', team)

    assert text == '&amp; &lt; &gt; \' "'

def test_linkifytext_names_with_paranthesis(realish_eventrouter):
    team = realish_eventrouter.teams.values()[0]

    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]

    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]

    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]

    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]

    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]

    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]

    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)

    assert text == '<#{}|{}>: my test message'.format(channel.id, channel.name)