Skip to content

Commit 64fae2d

Browse files
committed
lint
1 parent f4324fb commit 64fae2d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

jupyter_ai_router/tests/test_message_router.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
class TestUtils:
1414
"""Test utility functions."""
15-
15+
1616
def test_get_first_word_normal(self):
1717
"""Test getting first word from normal string."""
1818
assert get_first_word("hello world") == "hello"
1919
assert get_first_word(" hello world ") == "hello"
2020
assert get_first_word("/refresh-personas") == "/refresh-personas"
21-
21+
2222
def test_get_first_word_edge_cases(self):
2323
"""Test edge cases for get_first_word."""
2424
assert get_first_word("") is None
2525
assert get_first_word(" ") is None
2626
assert get_first_word("single") == "single"
27-
27+
2828
def test_is_persona(self):
2929
"""Test persona username detection."""
3030
assert is_persona("jupyter-ai-personas::jupyter_ai::JupyternautPersona") is True
@@ -34,74 +34,74 @@ def test_is_persona(self):
3434

3535
class TestMessageRouter:
3636
"""Test MessageRouter functionality."""
37-
37+
3838
def setup_method(self):
3939
"""Set up test fixtures."""
4040
self.router = MessageRouter()
4141
self.mock_chat_init_callback = Mock()
42-
self.mock_slash_cmd_callback = Mock()
42+
self.mock_slash_cmd_callback = Mock()
4343
self.mock_msg_callback = Mock()
4444
self.mock_ychat = Mock(spec=YChat)
4545
self.mock_ychat.ymessages = Mock()
46-
46+
4747
def test_router_initialization(self):
4848
"""Test router initializes correctly."""
4949
router = MessageRouter()
5050
assert len(router.chat_init_observers) == 0
5151
assert len(router.slash_cmd_observers) == 0
5252
assert len(router.chat_msg_observers) == 0
5353
assert len(router.active_chats) == 0
54-
54+
5555
def test_observe_chat_init(self):
5656
"""Test registering chat init callback."""
5757
self.router.observe_chat_init(self.mock_chat_init_callback)
5858
assert self.mock_chat_init_callback in self.router.chat_init_observers
59-
59+
6060
def test_observe_slash_cmd_msg(self):
6161
"""Test registering slash command callback."""
6262
room_id = "test-room"
6363
self.router.observe_slash_cmd_msg(room_id, self.mock_slash_cmd_callback)
6464
assert self.mock_slash_cmd_callback in self.router.slash_cmd_observers[room_id]
65-
65+
6666
def test_observe_chat_msg(self):
6767
"""Test registering regular message callback."""
6868
room_id = "test-room"
6969
self.router.observe_chat_msg(room_id, self.mock_msg_callback)
7070
assert self.mock_msg_callback in self.router.chat_msg_observers[room_id]
71-
71+
7272
def test_connect_chat(self):
7373
"""Test connecting a chat to the router."""
7474
room_id = "test-room"
7575
self.router.observe_chat_init(self.mock_chat_init_callback)
76-
76+
7777
self.router.connect_chat(room_id, self.mock_ychat)
78-
78+
7979
# Should store the chat and call init observers
8080
assert room_id in self.router.active_chats
8181
assert self.router.active_chats[room_id] == self.mock_ychat
8282
self.mock_chat_init_callback.assert_called_once_with(room_id, self.mock_ychat)
83-
83+
8484
def test_disconnect_chat(self):
8585
"""Test disconnecting a chat from the router."""
8686
room_id = "test-room"
8787
self.router.connect_chat(room_id, self.mock_ychat)
88-
88+
8989
self.router.disconnect_chat(room_id)
90-
90+
9191
# Should remove the chat
9292
assert room_id not in self.router.active_chats
93-
93+
9494
def test_message_routing(self):
9595
"""Test message routing to appropriate callbacks."""
9696
room_id = "test-room"
9797
self.router.observe_slash_cmd_msg(room_id, self.mock_slash_cmd_callback)
9898
self.router.observe_chat_msg(room_id, self.mock_msg_callback)
99-
99+
100100
# Test slash command routing
101101
slash_msg = Message(id="1", body="/test command", sender="user", time=123)
102102
self.router._route_message(room_id, slash_msg)
103103
self.mock_slash_cmd_callback.assert_called_once_with(room_id, slash_msg)
104-
104+
105105
# Test regular message routing
106106
regular_msg = Message(id="2", body="Hello world", sender="user", time=124)
107107
self.router._route_message(room_id, regular_msg)
@@ -112,11 +112,11 @@ def test_cleanup(self):
112112
room_id = "test-room"
113113
self.router.connect_chat(room_id, self.mock_ychat)
114114
self.router.observe_chat_init(self.mock_chat_init_callback)
115-
115+
116116
self.router.cleanup()
117-
117+
118118
# Should clear all observers and active chats
119119
assert len(self.router.active_chats) == 0
120120
assert len(self.router.chat_init_observers) == 0
121121
assert len(self.router.slash_cmd_observers) == 0
122-
assert len(self.router.chat_msg_observers) == 0
122+
assert len(self.router.chat_msg_observers) == 0

0 commit comments

Comments
 (0)