aboutsummaryrefslogblamecommitdiffstats
path: root/_pytest/test_unfurl.py
blob: 2168aedb2f725c0ee1492b68f8d0648a14f2e6f6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                


                 




                                  
      



                                                  
      


                                                        
      


                                          
      


                                                              
      


                                                                          
      


                                                                                                       
      

                                                           





                                    
 
                                                                                                                 
import wee_slack
import pytest

slack = wee_slack


@pytest.mark.parametrize('case', (
    {
        'input': "foo",
        'output': "foo",
    },
    {
        'input': "<@U2147483697|@othernick>: foo",
        'output': "@testuser: foo",
        'ignore_alt_text': True,
    },
    {
        'input': "foo <#C2147483705|#otherchannel> foo",
        'output': "foo #otherchannel foo",
    },
    {
        'input': "foo <#C2147483705> foo",
        'output': "foo #testchan foo",
    },
    {
        'input': "url: <https://example.com|example> suffix",
        'output': "url: https://example.com (example) suffix",
    },
    {
        'input': "url: <https://example.com|example with spaces> suffix",
        'output': "url: https://example.com (example with spaces) suffix",
    },
    {
        'input': "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>",
        'output': "@othernick multiple unfurl https://example.com (example with spaces)",
    },
))
def test_unfurl_refs(myservers, mychannels, myusers, case):
    slack.servers = myservers
    slack.channels = mychannels
    slack.users = myusers
    slack.message_cache = {}
    slack.servers[0].users = myusers
    print mychannels[0].identifier

    assert slack.unfurl_refs(case['input'], ignore_alt_text=case.get('ignore_alt_text', False)) == case['output']