Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[slack] Update function name for better readability
- detect_select_statement -> handle_select_statement
  • Loading branch information
Harshg999 committed May 20, 2021
1 parent d17a010 commit d5fb8e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions desktop/core/src/desktop/lib/botserver/views.py
Expand Up @@ -101,10 +101,10 @@ def handle_on_message(host_domain, is_http_secure, channel_id, bot_id, elements,
_send_message(channel_id, bot_message)

if text.lower().startswith('select'):
detect_select_statement(host_domain, is_http_secure, channel_id, user_id, text.lower())
handle_select_statement(host_domain, is_http_secure, channel_id, user_id, text.lower())


def detect_select_statement(host_domain, is_http_secure, channel_id, user_id, statement):
def handle_select_statement(host_domain, is_http_secure, channel_id, user_id, statement):
slack_user = check_slack_user_permission(host_domain, user_id)
user = get_user(channel_id, slack_user)

Expand Down
8 changes: 4 additions & 4 deletions desktop/core/src/desktop/lib/botserver/views_tests.py
Expand Up @@ -62,7 +62,7 @@ def setUp(self):

def test_handle_on_message(self):
with patch('desktop.lib.botserver.views._send_message') as _send_message:
with patch('desktop.lib.botserver.views.detect_select_statement') as detect_select_statement:
with patch('desktop.lib.botserver.views.handle_select_statement') as handle_select_statement:

channel_id = "channel"
bot_id = "bot_id"
Expand Down Expand Up @@ -97,9 +97,9 @@ def test_handle_on_message(self):
]

handle_on_message(self.host_domain, self.is_http_secure, channel_id, None, message_element, user_id)
detect_select_statement.assert_called_with(self.host_domain, self.is_http_secure, channel_id, user_id, 'select 1')
handle_select_statement.assert_called_with(self.host_domain, self.is_http_secure, channel_id, user_id, 'select 1')

def test_detect_select_statement(self):
def test_handle_select_statement(self):
with patch('desktop.lib.botserver.views.check_slack_user_permission') as check_slack_user:
with patch('desktop.lib.botserver.views.get_user') as get_user:
with patch('desktop.lib.botserver.views.get_cluster_config') as get_cluster_config:
Expand All @@ -119,7 +119,7 @@ def test_detect_select_statement(self):
'link': 'gist_link'
}

detect_select_statement(self.host_domain, self.is_http_secure, channel_id, user_id, statement)
handle_select_statement(self.host_domain, self.is_http_secure, channel_id, user_id, statement)
_send_message.assert_called_with(
channel_id,
('Hi <@user_id>\n'
Expand Down

0 comments on commit d5fb8e8

Please sign in to comment.