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


Commits:
1cbc1432 by wurstsalat at 2024-10-29T20:11:06+01:00
refactor: StartChart test: Generate limited set of avatars

- - - - -


1 changed file:

- test/gtk/test_start_chat.py


Changes:

=====================================
test/gtk/test_start_chat.py
=====================================
@@ -6,6 +6,7 @@
 
 import datetime as dt
 import random
+import string
 from collections.abc import Iterator
 from unittest.mock import MagicMock
 
@@ -75,6 +76,19 @@ class TestContactsModule:
     def __init__(self, account: str) -> None:
         self._account = account
 
+        self._avatars: list[Gdk.Texture] = []
+        alphabet = list(string.ascii_uppercase)
+        for _i in range(5):
+            color = (
+                random.randrange(100) / 100,
+                random.randrange(100) / 100,
+                random.randrange(100) / 100,
+            )
+            avatar = generate_default_avatar(
+                random.choice(alphabet), color, AvatarSize.CALL_BIG, 1
+            )
+            self._avatars.append(convert_surface_to_texture(avatar))
+
     def get_contact(self, jid: str | JID, groupchat: bool = False) -> 
BareContact:
         contact_name = f'Test Contact 
{random.randrange(CONTACTS_PER_ACCOUNT_COUNT)}'
 
@@ -87,11 +101,7 @@ def get_contact(self, jid: str | JID, groupchat: bool = 
False) -> BareContact:
         contact = MagicMock(spec_set=spec_set)
         contact.jid = jid
         contact.name = contact_name
-
-        avatar = convert_surface_to_texture(
-            generate_default_avatar('T', (0.2, 0.1, 0.7), AvatarSize.CALL_BIG, 
1)
-        )
-        contact.get_avatar = MagicMock(return_value=avatar)
+        contact.get_avatar = 
MagicMock(return_value=random.choice(self._avatars))
 
         contact.account = self._account
         contact.is_groupchat = groupchat



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/1cbc1432547a8a2f6a1d593343bc9472707dc4e0
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]

Reply via email to