Daniel Brötzmann pushed to branch gtk4 at gajim / gajim
Commits:
e11f71d2 by wurstsalat at 2024-11-07T20:01:58+01:00
refactor: Test: Improve PasswordDialog test
- - - - -
beae1c95 by wurstsalat at 2024-11-07T20:02:09+01:00
refactor: Test: Improve CallWindow test
- - - - -
2 changed files:
- test/gtk/ui_test_call_window.py
- test/gtk/ui_test_password_dialog.py
Changes:
=====================================
test/gtk/ui_test_call_window.py
=====================================
@@ -50,17 +50,16 @@ def get_contact(jid: str | JID) -> BareContact |
ResourceContact:
class TestClient:
- def __init__(self) -> None:
- pass
+ def __init__(self, account: str) -> None:
+ self.account = account
- @staticmethod
- def get_module(module: str) -> Any:
+ def get_module(self, module: str) -> Any:
if module == 'Contacts':
return TestContactsModule()
return MagicMock()
-app.get_client = MagicMock(return_value=TestClient)
+app.get_client = MagicMock(side_effect=TestClient)
app.call_manager = CallManager()
window = CallWindow(ACCOUNT, RESOURCE_JID)
=====================================
test/gtk/ui_test_password_dialog.py
=====================================
@@ -6,6 +6,8 @@
from unittest.mock import MagicMock
+from nbxmpp.protocol import JID
+
from gajim.common import app
from gajim.common.events import PasswordRequired
from gajim.common.settings import Settings
@@ -14,21 +16,31 @@
from . import util
-
-def on_password(*args: Any) -> None:
- print(args)
-
-
ACCOUNT = 'test'
+FROM_JID = '[email protected]'
app.settings = Settings(in_memory=True)
app.settings.init()
app.settings.add_account(ACCOUNT)
app.settings.set_account_setting(ACCOUNT, 'account_label', 'Test')
-app.get_client = MagicMock()
-client = MagicMock()
-client.account = ACCOUNT
+
+def on_password(*args: Any) -> None:
+ pass
+
+
+class TestClient:
+ def __init__(self, account: str) -> None:
+ self.account = account
+
+ def get_own_jid(self) -> JID:
+ return JID.from_string(FROM_JID)
+
+app.get_client = MagicMock(side_effect=TestClient)
+app.get_account_label = MagicMock(return_value='Test Account')
+
+client = app.get_client(ACCOUNT)
+
event = PasswordRequired(client, on_password)
window = PasswordDialog(event)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5dfffcf32cccf94a9ce0b27deaf0cd5e9a065704...beae1c950d9a050eb45315a08705240913922ae2
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5dfffcf32cccf94a9ce0b27deaf0cd5e9a065704...beae1c950d9a050eb45315a08705240913922ae2
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]