UQComputingSociety / uqcsbot-slack

:mortar_board: UQCSbot: our friendly little Slack bot
https://slack.uqcs.org.au
MIT License
55 stars 44 forks source link

test_yelling occasionally fails #495

Open bradleysigma opened 5 years ago

bradleysigma commented 5 years ago
    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.

bradleysigma commented 4 years ago

This is probably caused by the f"WHAT IS THE MEANING OF THIS ARCANE SYMBOL “{random_minuscule(text)}”‽ I RECOGNISE IT NOT!" and 'OH, NO! NOT THE `a`S! NOT THE `a`S! AAAAAHHHHH!' responses, which has a minuscule letting in it, causing the bot to reply to itself (thus three messages).

nicklambourne commented 4 years ago

You can fix this with a mock of random_minuscule.

bradleysigma commented 4 years ago

546 also fixes the problem (and in a better way, too).

bradleysigma commented 3 years ago

DISREGARD THAT.