Update
This commit is contained in:
parent
4f0d6ed76e
commit
fe28b04225
2 changed files with 1 additions and 30 deletions
|
@ -2,13 +2,7 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from nio import (
|
from nio import AsyncClient, MatrixRoom, RoomMemberEvent, RoomMessageText, UnknownEvent
|
||||||
AsyncClient,
|
|
||||||
MatrixRoom,
|
|
||||||
RoomMemberEvent,
|
|
||||||
RoomMessageText,
|
|
||||||
UnknownEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from nyx_bot.bot_commands import Command
|
from nyx_bot.bot_commands import Command
|
||||||
from nyx_bot.config import Config
|
from nyx_bot.config import Config
|
||||||
|
|
|
@ -5,8 +5,6 @@ import nio
|
||||||
|
|
||||||
from nyx_bot.callbacks import Callbacks
|
from nyx_bot.callbacks import Callbacks
|
||||||
|
|
||||||
from tests.utils import make_awaitable, run_coroutine
|
|
||||||
|
|
||||||
|
|
||||||
class CallbacksTestCase(unittest.TestCase):
|
class CallbacksTestCase(unittest.TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
|
@ -19,27 +17,6 @@ class CallbacksTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.callbacks = Callbacks(self.fake_client, self.fake_config)
|
self.callbacks = Callbacks(self.fake_client, self.fake_config)
|
||||||
|
|
||||||
def test_invite(self):
|
|
||||||
"""Tests the callback for InviteMemberEvents"""
|
|
||||||
# Tests that the bot attempts to join a room after being invited to it
|
|
||||||
|
|
||||||
# Create a fake room and invite event to call the 'invite' callback with
|
|
||||||
fake_room = Mock(spec=nio.MatrixRoom)
|
|
||||||
fake_room_id = "!abcdefg:example.com"
|
|
||||||
fake_room.room_id = fake_room_id
|
|
||||||
|
|
||||||
fake_invite_event = Mock(spec=nio.InviteMemberEvent)
|
|
||||||
fake_invite_event.sender = "@some_other_fake_user:example.com"
|
|
||||||
|
|
||||||
# Pretend that attempting to join a room is always successful
|
|
||||||
self.fake_client.join.return_value = make_awaitable(None)
|
|
||||||
|
|
||||||
# Pretend that we received an invite event
|
|
||||||
run_coroutine(self.callbacks.invite(fake_room, fake_invite_event))
|
|
||||||
|
|
||||||
# Check that we attempted to join the room
|
|
||||||
self.fake_client.join.assert_called_once_with(fake_room_id)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue