Repository: uqcomputingsociety/uqcsbot-slack
Issue: test_yelling occasionally fails

```python
    def test_minuscule(uqcsbot: MockUQCSBot):
        """
        test minuscule string
        """
        uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute")
>       assert len(uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])) == 2
E       AssertionError: assert 3 == 2
E        +  where 3 = len([{'channel': 'C1234567890', 'text': 'wintermute', 'ts': '1573201241.7311587', 'type': 'message', ...}, {'channel': 'C1... 'message', ...}, {'channel': 'C1234567890', 'text': 'WHAT’S THAT‽', 'ts': '1573201241.73277', 'type': 'message', ...}])
E        +    where [{'channel': 'C1234567890', 'text': 'wintermute', 'ts': '1573201241.7311587', 'type': 'message', ...}, {'channel': 'C1... 'message', ...}, {'channel': 'C1234567890', 'text': 'WHAT’S THAT‽', 'ts': '1573201241.73277', 'type': 'message', ...}] = <built-in method get of collections.defaultdict object at 0x7fffead14db8>('C1234567890', [])
E        +      where <built-in method get of collections.defaultdict object at 0x7fffead14db8> = defaultdict(<class 'list'>, {'C1234567890': [{'type': 'message', 'ts': '1573201241.7311587', 'user': 'B1234567890', 't...type': 'message', 'ts': '1573201241.73277', 'user': 'B1234567890', 'text': 'WHAT’S THAT‽', 'channel': 'C1234567890'}]}).get
E        +        where defaultdict(<class 'list'>, {'C1234567890': [{'type': 'message', 'ts': '1573201241.7311587', 'user': 'B1234567890', 't...type': 'message', 'ts': '1573201241.73277', 'user': 'B1234567890', 'text': 'WHAT’S THAT‽', 'channel': 'C1234567890'}]}) = <test.conftest.MockUQCSBot object at 0x7fffead1e908>.test_messages

test/test_yelling.py:12: AssertionError
```

Commenting `retest this please` can cause the tests to pass.

Changed files:
uqcsbot/scripts/yelling.py, test/test_yelling.py

diff --git a/test/test_yelling.py b/test/test_yelling.py
index ad618e8..fd9daef 100644
--- a/test/test_yelling.py
+++ b/test/test_yelling.py
@@ -1,4 +1,4 @@
-from test.conftest import MockUQCSBot, TEST_CHANNEL_ID
+from test.conftest import MockUQCSBot, TEST_CHANNEL_ID, TEST_USER_ID
 from unittest.mock import patch
 from typing import Mapping, TypeVar, Generator, Any, List
 
@@ -30,92 +30,88 @@ def count_lowercase_msgs(uqcsbot):
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_minuscule(uqcsbot: MockUQCSBot):
     """
     test minuscule string
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 2
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_majuscule(uqcsbot: MockUQCSBot):
     """
     test majuscule string
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_mixed(uqcsbot: MockUQCSBot):
     """
     test mixed case string
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "wiNTErMUTe")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "wiNTErMUTe", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 2
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: False)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_channel(uqcsbot: MockUQCSBot):
     """
     tests outside of #yeling
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_thread_discreet_minuscule(uqcsbot: MockUQCSBot):
     """
     test minuscule string reply to thread
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
     thread = float(uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])[-1].get('ts', 0))
-    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute", reply_broadcast=False, thread_ts=thread)
+    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute",
+                         reply_broadcast=False, thread_ts=thread, user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 3
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_thread_discreet_majuscule(uqcsbot: MockUQCSBot):
     """
     test majuscule string reply to thread
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
     thread = float(uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])[-1].get('ts', 0))
-    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE", reply_broadcast=False, thread_ts=thread)
+    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE",
+                         reply_broadcast=False, thread_ts=thread, user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 2
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_thread_blatant_minuscule(uqcsbot: MockUQCSBot):
     """
     test minuscule string reply to thread and channel
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
     thread = float(uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])[-1].get('ts', 0))
-    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute", reply_broadcast=True, thread_ts=thread)
+    uqcsbot.post_message(TEST_CHANNEL_ID, "wintermute",
+                         reply_broadcast=True, thread_ts=thread, user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 3
 
 
 @patch("uqcsbot.scripts.yelling.in_yelling", new=lambda chan: True)
-@patch("uqcsbot.scripts.yelling.is_human", new=lambda chan: True)
 def test_thread_blatant_majuscule(uqcsbot: MockUQCSBot):
     """
     test majuscule string reply to thread and channel
     """
-    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER")
+    uqcsbot.post_message(TEST_CHANNEL_ID, "NEUROMANCER", user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 1
     thread = float(uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])[-1].get('ts', 0))
-    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE", reply_broadcast=True, thread_ts=thread)
+    uqcsbot.post_message(TEST_CHANNEL_ID, "WINTERMUTE",
+                         reply_broadcast=True, thread_ts=thread, user=TEST_USER_ID)
     assert count_lowercase_msgs(uqcsbot) == 2
diff --git a/uqcsbot/scripts/yelling.py b/uqcsbot/scripts/yelling.py
index 9dc57af..d1426e9 100644
--- a/uqcsbot/scripts/yelling.py
+++ b/uqcsbot/scripts/yelling.py
@@ -13,14 +13,6 @@ def in_yelling(channel):
     return chan and (chan.name == "yelling" or chan.name == "cheering")
 
 
-def is_human(user):
-    """
-    checks that the user is not a bot
-    exists for test mocking
-    """
-    return user is not None and not user.is_bot
-
-
 def mutate_minuscule(message: str) -> str:
     """
     Randomly mutates 40% of minuscule letters to other minuscule letters
@@ -62,7 +54,7 @@ def yelling(event: dict):
 
     # ensure user proper
     user = bot.users.get(event.get("user"))
-    if not is_human(user):
+    if user is None or user.is_bot:
         return
 
     # ignore emoji