Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit c59b9b2

Browse files
committed
chore: replace method to get chat names
1 parent 75e2117 commit c59b9b2

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

gui/screens/messages.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,10 @@ def __init__(self):
3535
self._chat_list_item = QObject(messaging_names.scrollView_StatusChatListItem)
3636

3737
@property
38-
@allure.step('Get contacts')
39-
def chats(self) -> typing.List[str]:
38+
@allure.step('Get chats by chats list')
39+
def get_chats_names(self) -> typing.List[str]:
4040
return self._chats_list.get_values('objectName')
4141

42-
@allure.step('Open chat')
43-
def get_chats_list(self):
44-
started_at = time.monotonic()
45-
chats_list = []
46-
while True:
47-
for obj in driver.findAllObjects(self._chat_list_item.real_name):
48-
chats_list.append(str(obj.name))
49-
if time.monotonic() - started_at > 10 and len(chats_list) == 0:
50-
raise LookupError('Chats list is empty')
51-
else:
52-
return chats_list
53-
5442
@allure.step('Click chat item')
5543
def click_chat_by_name(self, chat_name: str):
5644
self._chat_list_item.real_name['objectName'] = chat_name

tests/messages/test_messaging_group_chat.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_
3737
main_window = MainWindow()
3838
messages_screen = MessagesScreen()
3939

40-
with multiple_instances(user_data=user_data_one) as aut_one, multiple_instances(user_data=user_data_two) as aut_two, multiple_instances(
40+
with multiple_instances(user_data=user_data_one) as aut_one, multiple_instances(
41+
user_data=user_data_two) as aut_two, multiple_instances(
4142
user_data=user_data_three) as aut_three:
4243
with step(f'Launch multiple instances with authorized users {user_one.name}, {user_two.name}, {user_three}'):
4344
for aut, account in zip([aut_one, aut_two, aut_three], [user_one, user_two, user_three]):
@@ -100,7 +101,7 @@ def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_
100101
with step(f'Check group members and message for {user_two.name}'):
101102
aut_two.attach()
102103
main_window.prepare()
103-
assert group_chat_new_name in messages_screen.left_panel.get_chats_list(), \
104+
assert group_chat_new_name in messages_screen.left_panel.get_chats_names, \
104105
f'{group_chat_new_name} is not present in chats list for {aut_two}'
105106
messages_screen.left_panel.click_chat_by_name(group_chat_new_name)
106107

@@ -123,15 +124,15 @@ def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_
123124
messages_screen.left_panel.open_leave_group_popup(group_chat_new_name).confirm_leaving()
124125

125126
with step('Check that group name is not displayed on left panel'):
126-
assert group_chat_new_name not in messages_screen.left_panel.get_chats_list()
127+
assert group_chat_new_name not in messages_screen.left_panel.get_chats_names
127128
main_window.hide()
128129

129130
with step(f'Check group members and message for {user_three.name}'):
130131
aut_three.attach()
131132
main_window.prepare()
132133

133134
with step(f'Check that {user_three.name} is not a member of a group'):
134-
assert group_chat_new_name in messages_screen.left_panel.get_chats_list(), \
135+
assert group_chat_new_name in messages_screen.left_panel.get_chats_names, \
135136
f'{group_chat_new_name} is not present in chats list for {aut_three}'
136137
messages_screen.left_panel.click_chat_by_name(group_chat_new_name)
137138
gray_message_text = messages_screen.group_chat.gray_text_from_message_area
@@ -140,22 +141,22 @@ def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_
140141

141142
with step('Verify members in a group members list'):
142143
assert user_one.name in messages_screen.right_panel.members
143-
assert user_two.name in messages_screen.right_panel.members is False
144+
assert user_two.name in messages_screen.right_panel.members
144145
assert user_three.name in messages_screen.right_panel.members is False
145-
assert len(messages_screen.right_panel.members) == 2 # it has to be 2 since user3 is kicked and not
146+
assert len(messages_screen.right_panel.members) == 2 # it has to be 2 since user3 is kicked and not
146147
# receiving any updates from that moment
147148

148149
with step('Leave group'):
149150
messages_screen.group_chat.leave_group().confirm_leaving()
150151

151152
with step('Check that group name is not displayed on left panel'):
152-
assert group_chat_new_name not in messages_screen.left_panel.get_chats_list()
153+
assert group_chat_new_name not in messages_screen.left_panel.get_chats_names
153154
main_window.hide()
154155

155156
with step(f'Get back to {aut_one} and check members list'):
156157
aut_one.attach()
157158
main_window.prepare()
158-
assert group_chat_new_name in messages_screen.left_panel.get_chats_list(), \
159+
assert group_chat_new_name in messages_screen.left_panel.get_chats_names, \
159160
f'{group_chat_new_name} is not present in chats list for {aut_one}'
160161
messages_screen.left_panel.click_chat_by_name(group_chat_new_name)
161162
assert user_one.name in messages_screen.right_panel.members
@@ -165,4 +166,4 @@ def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_
165166
messages_screen.group_chat.leave_group().confirm_leaving()
166167

167168
with step('Check that group name is not displayed on left panel'):
168-
assert group_chat_new_name in messages_screen.left_panel.get_chats_list() is False
169+
assert group_chat_new_name in messages_screen.left_panel.get_chats_names is False

tests/settings/settings_messaging/test_messaging_settings_accept_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ def test_messaging_settings_accepting_request(multiple_instances):
9595

9696
with step(f'Verify that 1X1 chat with {user_two.name} appeared for {user_one.name}'):
9797
messages_screen = main_window.left_panel.open_messages_screen()
98-
assert user_two.name in messages_screen.left_panel.get_chats_list()
98+
assert user_two.name in messages_screen.left_panel.get_chats_names
9999
main_window.hide()
100100

101101
with step(f'Verify that 1X1 chat with {user_one.name} appeared for {user_two.name}'):
102102
aut_two.attach()
103103
main_window.prepare()
104104
messages_screen = main_window.left_panel.open_messages_screen()
105-
assert user_one.name in messages_screen.left_panel.get_chats_list()
105+
assert user_one.name in messages_screen.left_panel.get_chats_names

0 commit comments

Comments
 (0)