78 lines
3.2 KiB
Python
78 lines
3.2 KiB
Python
|
import typing
|
||
|
|
||
|
import allure
|
||
|
|
||
|
import driver
|
||
|
from constants import UserCommunity
|
||
|
from driver import objects_access
|
||
|
from gui.elements.qt.button import Button
|
||
|
from gui.elements.qt.object import QObject
|
||
|
from gui.elements.qt.text_label import TextLabel
|
||
|
from gui.screens.community_settings import CommunitySettingsScreen
|
||
|
|
||
|
|
||
|
class SettingsScreen(QObject):
|
||
|
|
||
|
def __init__(self):
|
||
|
super().__init__('mainWindow_ProfileLayout')
|
||
|
self._settings_section_template = QObject('scrollView_AppMenuItem_StatusNavigationListItem')
|
||
|
|
||
|
def _open_settings(self, index: int):
|
||
|
self._settings_section_template.real_name['objectName'] = f'{index}-AppMenuItem'
|
||
|
self._settings_section_template.click()
|
||
|
|
||
|
@allure.step('Open communities settings')
|
||
|
def open_communities_settings(self):
|
||
|
self._open_settings(12)
|
||
|
return CommunitiesSettingsView()
|
||
|
|
||
|
|
||
|
class CommunitiesSettingsView(QObject):
|
||
|
|
||
|
def __init__(self):
|
||
|
super().__init__('mainWindow_CommunitiesView')
|
||
|
self._community_item = QObject('settingsContentBaseScrollView_listItem_StatusListItem')
|
||
|
self._community_template_image = QObject('settings_iconOrImage_StatusSmartIdenticon')
|
||
|
self._community_template_name = TextLabel('settings_Name_StatusTextWithLoadingState')
|
||
|
self._community_template_description = TextLabel('settings_statusListItemSubTitle')
|
||
|
self._community_template_members = TextLabel('settings_member_StatusTextWithLoadingState')
|
||
|
self._community_template_button = Button('settings_StatusFlatButton')
|
||
|
|
||
|
@property
|
||
|
@allure.step('Get communities')
|
||
|
def communities(self) -> typing.List[UserCommunity]:
|
||
|
_communities = []
|
||
|
for obj in driver.findAllObjects(self._community_item.real_name):
|
||
|
container = driver.objectMap.realName(obj)
|
||
|
self._community_template_image.real_name['container'] = container
|
||
|
self._community_template_name.real_name['container'] = container
|
||
|
self._community_template_description.real_name['container'] = container
|
||
|
self._community_template_members.real_name['container'] = container
|
||
|
|
||
|
_communities.append(UserCommunity(
|
||
|
self._community_template_name.text,
|
||
|
self._community_template_description.text,
|
||
|
self._community_template_members.text,
|
||
|
self._community_template_image.image
|
||
|
))
|
||
|
return _communities
|
||
|
|
||
|
def _get_community_item(self, name: str):
|
||
|
for obj in driver.findAllObjects(self._community_item.real_name):
|
||
|
for item in objects_access.walk_children(obj):
|
||
|
if getattr(item, 'text', '') == name:
|
||
|
return obj
|
||
|
raise LookupError(f'Community item: {name} not found')
|
||
|
|
||
|
@allure.step('Open community info')
|
||
|
def get_community_info(self, name: str) -> UserCommunity:
|
||
|
for community in self.communities:
|
||
|
if community.name == name:
|
||
|
return community
|
||
|
raise LookupError(f'Community item: {name} not found')
|
||
|
|
||
|
@allure.step('Open community overview settings')
|
||
|
def open_community_overview_settings(self, name: str):
|
||
|
driver.mouseClick(self._get_community_item(name))
|
||
|
return CommunitySettingsScreen().wait_until_appears()
|