Browse Source

[slack] Update function name for better readability

- detect_select_statement -> handle_select_statement
Harshg999 4 years ago
parent
commit
d5fb8e849a

+ 2 - 2
desktop/core/src/desktop/lib/botserver/views.py

@@ -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)
 

+ 4 - 4
desktop/core/src/desktop/lib/botserver/views_tests.py

@@ -62,7 +62,7 @@ class TestBotServer(unittest.TestCase):
 
   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"
@@ -97,9 +97,9 @@ class TestBotServer(unittest.TestCase):
         ]
 
         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:
@@ -119,7 +119,7 @@ class TestBotServer(unittest.TestCase):
                 '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'