Daniel Brötzmann pushed to branch newcontrol at gajim / gajim


Commits:
1cc7bd98 by wurstsalat at 2022-07-12T18:18:19+02:00
Fix test, fix linter errors

- - - - -


3 changed files:

- gajim/gtk/chat_stack.py
- gajim/gtk/control_stack.py
- test/no_gui/test_nick_completion.py


Changes:

=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -304,6 +304,7 @@ def _on_action(self,
             open_window('AddContact', account=account, jid=jid)
 
         elif action_name == 'clear-chat':
+            assert current_control is not None
             current_control.reset_view()
 
         elif action_name == 'show-contact-info':
@@ -386,6 +387,7 @@ def _on_send_message(self) -> None:
         message = self._message_action_box.msg_textview.get_text()
 
         control = self._control_stack.get_current_control()
+        assert control is not None
 
         action = app.window.lookup_action('set-encryption')
         assert action is not None


=====================================
gajim/gtk/control_stack.py
=====================================
@@ -40,7 +40,7 @@ def __init__(self):
 
         self.show_all()
         self._controls: dict[tuple[str, JID], ControlT] = {}
-        self._current_control = None
+        self._current_control: Optional[ControlT] = None
 
     def get_control(self, account: str, jid: JID) -> Optional[ControlT]:
         try:
@@ -48,7 +48,7 @@ def get_control(self, account: str, jid: JID) -> 
Optional[ControlT]:
         except KeyError:
             return None
 
-    def get_current_control(self) -> ControlT:
+    def get_current_control(self) -> Optional[ControlT]:
         return self._current_control
 
     def get_controls(self, account: Optional[str]


=====================================
test/no_gui/test_nick_completion.py
=====================================
@@ -1,5 +1,4 @@
 import unittest
-from unittest.mock import MagicMock
 
 from gajim import gui
 gui.init('gtk')
@@ -10,8 +9,7 @@
 class Test(unittest.TestCase):
 
     def test_generate_suggestions(self):
-        message_input = MagicMock()
-        gen = GroupChatNickCompletion(message_input)
+        gen = GroupChatNickCompletion()
 
         l = ['aaaa', 'fooo', 'xxxxz', 'xaaaz']
         for n in l:
@@ -45,7 +43,7 @@ def test_generate_suggestions(self):
         old_name = 'aaaa'
         new_name = 'bbbb'
 
-        for lst in (gen._attention_list, gen._sender_list):
+        for lst in (gen._highlight_list, gen._sender_list):
             for idx, contact in enumerate(lst):
                 if contact == old_name:
                     lst[idx] = new_name



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/1cc7bd9839a877aa047d9ae2b61c4bc4f9511483

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/1cc7bd9839a877aa047d9ae2b61c4bc4f9511483
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to