diff options
-rw-r--r-- | _pytest/test_unfurl.py | 36 | ||||
-rw-r--r-- | wee_slack.py | 4 |
2 files changed, 19 insertions, 21 deletions
diff --git a/_pytest/test_unfurl.py b/_pytest/test_unfurl.py index b631888..eebe446 100644 --- a/_pytest/test_unfurl.py +++ b/_pytest/test_unfurl.py @@ -10,17 +10,17 @@ slack = wee_slack 'output': "foo", }, { - 'input': "<@U2147483697|@othernick>: foo", - 'output': "@testuser: foo", + 'input': "<@U407ABLLW|@othernick>: foo", + 'output': "@alice: foo", 'ignore_alt_text': True, }, { - 'input': "foo <#C2147483705|#otherchannel> foo", + 'input': "foo <#C407ABS94|otherchannel> foo", 'output': "foo #otherchannel foo", }, { - 'input': "foo <#C2147483705> foo", - 'output': "foo #test-chan foo", + 'input': "foo <#C407ABS94> foo", + 'output': "foo #general foo", }, { 'input': "url: <https://example.com|example> suffix", @@ -31,23 +31,21 @@ slack = wee_slack 'output': "url: https://example.com (example with spaces) suffix", }, { - 'input': "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>", + 'input': "<@U407ABLLW|@othernick> multiple unfurl <https://example.com|example with spaces>", 'output': "@othernick multiple unfurl https://example.com (example with spaces)", }, { - 'input': "try the #test-chan channel", - 'output': "try the #test-chan channel", + 'input': "try the #general channel", + 'output': "try the #general channel", + }, + { + 'input': "<@U407ABLLW> I think 3 > 2", + 'output': "@alice I think 3 > 2", }, )) -def test_unfurl_refs(case): - pass - #print myslack - #slack.servers = myslack.server - #slack.channels = myslack.channel - #slack.users = myslack.user - #slack.message_cache = {} - #slack.servers[0].users = myslack.user - #print myslack.channel[0].identifier - - #assert slack.unfurl_refs(case['input'], ignore_alt_text=case.get('ignore_alt_text', False)) == case['output'] +def test_unfurl_refs(case, realish_eventrouter): + slack.EVENTROUTER = realish_eventrouter + result = slack.unfurl_refs( + case['input'], ignore_alt_text=case.get('ignore_alt_text', False)) + assert result == case['output'] diff --git a/wee_slack.py b/wee_slack.py index 3904ab0..be0558e 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2126,7 +2126,7 @@ def handle_imopen(im_json, eventrouter, **kwargs): im = team.channels[request_metadata.channel_identifier] unread_count_display = im_json['channel']['unread_count_display'] im.set_unread_count_display(unread_count_display) - + def handle_groupshistory(message_json, eventrouter, **kwargs): handle_history(message_json, eventrouter, **kwargs) @@ -2581,7 +2581,7 @@ def unfurl_refs(text, ignore_alt_text=False): # - <#C2147483705|#otherchannel> # - <@U2147483697|@othernick> # Test patterns lives in ./_pytest/test_unfurl.py - matches = re.findall(r"(<[@#]?(?:[^<]*)>)", text) + matches = re.findall(r"(<[@#]?(?:[^>]*)>)", text) for m in matches: # Replace them with human readable strings text = text.replace(m, unfurl_ref(m[1:-1], ignore_alt_text)) |