aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-08-24 20:49:12 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-08-25 19:42:06 +0200
commit64cf9f64e1097f8b4dacf08c9c6cc6a6baeb77a3 (patch)
tree935792fc4512428bba7e75c4c88c229a70da4be3 /_pytest
parent6042a85c9b2e9bf266d3225a2a878583ea5b944d (diff)
downloadwee-slack-64cf9f64e1097f8b4dacf08c9c6cc6a6baeb77a3.tar.gz
Add some more tests for linkify_text
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/conftest.py12
-rw-r--r--_pytest/test_linkifytext.py27
2 files changed, 39 insertions, 0 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py
index 87fa834..e997bf6 100644
--- a/_pytest/conftest.py
+++ b/_pytest/conftest.py
@@ -60,6 +60,18 @@ def channel_general(team):
return team.channels[team.get_channel_map()['#general']]
@pytest.fixture
+def channel_private(team):
+ return team.channels[team.get_channel_map()['&some-private-channel']]
+
+@pytest.fixture
+def channel_dm(team):
+ return team.channels[team.get_channel_map()['alice']]
+
+@pytest.fixture
+def channel_mpdm(team):
+ return team.channels[team.get_channel_map()['CharlesTestuser,alice']]
+
+@pytest.fixture
def user_alice(team):
return team.users[team.get_username_map()['alice']]
diff --git a/_pytest/test_linkifytext.py b/_pytest/test_linkifytext.py
index fb251b8..a086fde 100644
--- a/_pytest/test_linkifytext.py
+++ b/_pytest/test_linkifytext.py
@@ -49,8 +49,35 @@ def test_linkifytext_at_channel(team):
assert text == '<!channel>: my test message'
+def test_linkifytext_at_group(team):
+ text = linkify_text('@group: my test message', team)
+
+ assert text == '<!group>: my test message'
+
+def test_linkifytext_at_here(team):
+ text = linkify_text('@here: my test message', team)
+
+ assert text == '<!here>: my test message'
+
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_general.id, channel_name)
+
+def test_linkifytext_not_private_using_hash(team, channel_private):
+ channel_name = re.sub(r'^[#&]', '', channel_private.name)
+ text = linkify_text('#{}: my test message'.format(channel_name), team)
+
+ assert text == '#{}: my test message'.format(channel_name)
+
+def test_linkifytext_not_private_using_ampersand(team, channel_private):
+ channel_name = re.sub(r'^[#&]', '', channel_private.name)
+ text = linkify_text('&{}: my test message'.format(channel_name), team)
+
+ assert text == '&amp;{}: my test message'.format(channel_name)
+
+def test_linkifytext_not_dm(team, channel_dm):
+ text = linkify_text('#{}: my test message'.format(channel_dm.name), team)
+
+ assert text == '#{}: my test message'.format(channel_dm.name)