Skip to content

Commit

Permalink
Use schnick, schnack, schnuck
Browse files Browse the repository at this point in the history
  • Loading branch information
filipre committed May 29, 2024
1 parent bb1e084 commit 063a09d
Showing 1 changed file with 6 additions and 51 deletions.
57 changes: 6 additions & 51 deletions tests/test_chat.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import unittest
from unittest.mock import patch
import asyncio
import logging
from signalbot import Command, Context
from signalbot.utils import (
ChatTestCase,
SendMessagesMock,
ReceiveMessagesMock,
chat,
)


class OneTwoThreeCommand(Command):
triggers = ["one", "two"]
class SchnickSchnackSchnuckCommand(Command):
triggers = ["schnick", "schnack"]

def __init__(self, listen):
self.listen = listen
Expand All @@ -22,55 +15,17 @@ async def handle(self, c: Context) -> bool:
return

text = c.message.text
if text == "one":
if text == "schnick":
await asyncio.sleep(1)
await c.send("two", listen=self.listen)
await c.send("schnack", listen=self.listen)
return

if text == "two":
if text == "schnack":
await asyncio.sleep(1)
await c.send("three")
await c.send("schnuck")
return


# class EnabledListenChatTest(ChatTestCase):
# def setUp(self):
# super().setUp()
# self.signal_bot.register(OneTwoThreeCommand(listen=True))

# @patch("signalbot.SignalAPI.send", new_callable=SendMessagesMock)
# @patch("signalbot.SignalAPI.receive", new_callable=ReceiveMessagesMock)
# async def test_chat(self, receive_mock, send_mock):
# receive_mock.define(["one"])
# await self.run_bot()
# self.assertEqual(send_mock.call_count, 2)


# class DisabledListenChatTest(ChatTestCase):
# def setUp(self):
# super().setUp()
# group = {"id": "asdf", "name": "Test"}
# self.signal_bot._groups_by_internal_id = {"group_id1=": group}
# self.signal_bot.register(OneTwoThreeCommand(listen=False))

# @patch("signalbot.SignalAPI.send", new_callable=SendMessagesMock)
# @patch("signalbot.SignalAPI.receive", new_callable=ReceiveMessagesMock)
# async def test_chat(self, receive_mock, send_mock):
# receive_mock.define(["one"])
# await self.run_bot()
# self.assertEqual(send_mock.call_count, 1)


# class DecoratorChatTest(ChatTestCase):
# def setUp(self):
# super().setUp()
# self.signal_bot.register(OneTwoThreeCommand(listen=True))

# @chat("how are you doing", "one")
# def test_chat(self, query, replies, reactions):
# self.assertEqual(replies.call_count, 2)


if __name__ == "__main__":
logging.basicConfig(level="INFO")
unittest.main()

0 comments on commit 063a09d

Please sign in to comment.