pinterest / slackminion

A python bot framework for slack
MIT License
22 stars 14 forks source link

Fix all_names attribute in SlackConversation, improve test coverage #51

Closed amckenna-pinterest closed 3 years ago

amckenna-pinterest commented 3 years ago
>>> c = {
    'id': 'C02KT31H9GX',
    'name': 'TEST-channel',
    'is_channel': True,
    'is_group': False,
    'is_im': False,
    'is_mpim': False,
    'is_private': False,
    'name_normalized': 'test-channel',
    'topic': {'value': '', 'creator': '', 'last_set': 0},
    'previous_names': ['old-test-channel-name', 'some-other-name'],
    'priority': 0
}
>>> from slackminion.slack.conversation import SlackConversation
>>> from unittest import mock
>>> a = mock.Mock()
>>> s = SlackConversation(c, a)
>>> s.name
'TEST-channel'
>>> s.id
'C02KT31H9GX'
>>> s.name_normalized
'test-channel'
>>> s.all_names
['TEST-channel', 'test-channel', 'old-test-channel-name', 'some-other-name']
>>> conversations = [s]
>>> [x for x in conversations if 'some-other-name' in x.all_names]
[<#C02KT31H9GX|TEST-channel>]
>>> [x for x in conversations if 'old-test-channel-name' in x.all_names]
[<#C02KT31H9GX|TEST-channel>]
>>> [x for x in conversations if 'TEST-channel' in x.all_names]
[<#C02KT31H9GX|TEST-channel>]