From 77379a33df1ee256deaab31146575c4e61962fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 1 Dec 2023 14:58:22 +0100 Subject: [PATCH] chore(all): rename _logger to LOG to match changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of them were renamed in: https://github.com/status-im/desktop-qa-automation/pull/352 Signed-off-by: Jakub SokoĊ‚owski --- configs/__init__.py | 2 +- driver/objects_access.py | 2 +- fixtures/path.py | 12 ++++++------ .../community/create_community_popups.py | 4 ++-- gui/components/os/open_file_dialogs.py | 2 +- gui/elements/button.py | 4 ++-- gui/elements/check_box.py | 4 ++-- gui/elements/list.py | 6 +++--- gui/elements/object.py | 14 +++++++------- gui/elements/scroll.py | 8 ++++---- gui/elements/slider.py | 4 ++-- gui/elements/text_edit.py | 6 +++--- gui/elements/text_label.py | 2 +- gui/elements/window.py | 18 +++++++++--------- gui/main_window.py | 2 +- gui/screens/onboarding.py | 2 +- gui/screens/settings_communities.py | 4 ++-- scripts/tools/image.py | 16 ++++++++-------- scripts/utils/system_path.py | 2 +- .../test_onboarding_generate_new_keys.py | 2 +- 20 files changed, 58 insertions(+), 58 deletions(-) diff --git a/configs/__init__.py b/configs/__init__.py index 7b14d48..f60383c 100644 --- a/configs/__init__.py +++ b/configs/__init__.py @@ -4,7 +4,7 @@ from os import path from scripts.utils.system_path import SystemPath from . import testpath, timeouts, testrail, squish, system -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) try: from ._local import * diff --git a/driver/objects_access.py b/driver/objects_access.py index ad35c81..59385c6 100644 --- a/driver/objects_access.py +++ b/driver/objects_access.py @@ -2,7 +2,7 @@ import logging import object -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) def walk_children(parent, depth: int = 1000): diff --git a/fixtures/path.py b/fixtures/path.py index dbdfa92..199d000 100644 --- a/fixtures/path.py +++ b/fixtures/path.py @@ -6,7 +6,7 @@ import pytest import configs from scripts.utils.system_path import SystemPath -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) @pytest.fixture @@ -16,11 +16,11 @@ def generate_test_data(request): node_dir = configs.testpath.TEST / test_params configs.testpath.TEST_ARTIFACTS = node_dir / 'artifacts' configs.testpath.TEST_VP = configs.testpath.VP / test_path / test_name - _logger.debug('Artifacts directory: %s', + LOG.debug('Artifacts directory: %s', configs.testpath.TEST_ARTIFACTS.relative_to(configs.testpath.ROOT)) - _logger.debug('Verification points directory: %s', + LOG.debug('Verification points directory: %s', configs.testpath.TEST_VP.relative_to(configs.testpath.ROOT)) - _logger.info(f'Start test: {test_name}') + LOG.info(f'Start test: {test_name}') def generate_test_info(node): @@ -40,6 +40,6 @@ def prepare_test_directory(): del_runs = runs[:len(runs) - keep_results] for run in del_runs: SystemPath(run).rmtree(ignore_errors=True) - _logger.info(f"Remove old test run directory: {run.relative_to(configs.testpath.ROOT)}") + LOG.info(f"Remove old test run directory: {run.relative_to(configs.testpath.ROOT)}") configs.testpath.RUN.mkdir(parents=True, exist_ok=True) - _logger.info(f"Created new test run directory: {configs.testpath.RUN.relative_to(configs.testpath.ROOT)}") + LOG.info(f"Created new test run directory: {configs.testpath.RUN.relative_to(configs.testpath.ROOT)}") diff --git a/gui/components/community/create_community_popups.py b/gui/components/community/create_community_popups.py index 968552e..fa31988 100644 --- a/gui/components/community/create_community_popups.py +++ b/gui/components/community/create_community_popups.py @@ -14,7 +14,7 @@ from gui.elements.scroll import Scroll from gui.elements.text_edit import TextEdit from gui.screens.community import CommunityScreen -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class CreateCommunitiesBanner(BasePopup): @@ -78,7 +78,7 @@ class CreateCommunityPopup(BasePopup): return OpenFileDialog().wait_until_appears() except LookupError as err: if attempt: - _logger.debug(err) + LOG.debug(err) return self._open_logo_file_dialog(attempt - 1) else: raise diff --git a/gui/components/os/open_file_dialogs.py b/gui/components/os/open_file_dialogs.py index 90f4571..6ecb78f 100644 --- a/gui/components/os/open_file_dialogs.py +++ b/gui/components/os/open_file_dialogs.py @@ -7,7 +7,7 @@ from gui.elements.text_edit import TextEdit from gui.elements.window import Window from scripts.utils.system_path import SystemPath -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class OpenFileDialog(Window): diff --git a/gui/elements/button.py b/gui/elements/button.py index 376670b..7ae1191 100644 --- a/gui/elements/button.py +++ b/gui/elements/button.py @@ -6,7 +6,7 @@ import allure import driver from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class Button(QObject): @@ -20,6 +20,6 @@ class Button(QObject): ): if None not in (x, y, button): getattr(self.object, 'clicked')() - _logger.info(f'{self}: clicked') + LOG.info(f'{self}: clicked') else: super(Button, self).click(x, y, button) diff --git a/gui/elements/check_box.py b/gui/elements/check_box.py index 9703179..6461606 100644 --- a/gui/elements/check_box.py +++ b/gui/elements/check_box.py @@ -6,7 +6,7 @@ import configs import driver from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class CheckBox(QObject): @@ -17,4 +17,4 @@ class CheckBox(QObject): self.click(x, y) assert driver.waitFor( lambda: self.is_checked is value, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Value not changed' - _logger.info(f'{self}: value changed to "{value}"') + LOG.info(f'{self}: value changed to "{value}"') diff --git a/gui/elements/list.py b/gui/elements/list.py index 2204855..f1928ff 100644 --- a/gui/elements/list.py +++ b/gui/elements/list.py @@ -8,7 +8,7 @@ import configs import driver from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class List(QObject): @@ -30,7 +30,7 @@ class List(QObject): @allure.step('Select item {1} in {0}') def select(self, value: str, attr_name: str): driver.mouseClick(self.wait_for_item(value, attr_name)) - _logger.info(f'{self}: {value} selected') + LOG.info(f'{self}: {value} selected') @allure.step('Wait for item {1} in {0} with attribute {2}') def wait_for_item(self, value: str, attr_name: str, timeout_sec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC): @@ -40,7 +40,7 @@ class List(QObject): for index in range(self.object.count): cur_value = str(getattr(self.object.itemAtIndex(index), attr_name, '')) if cur_value == value: - _logger.info(f'{self}: "{value}" for attribute "{attr_name}" appeared') + LOG.info(f'{self}: "{value}" for attribute "{attr_name}" appeared') return self.object.itemAtIndex(index) values.append(cur_value) time.sleep(1) diff --git a/gui/elements/object.py b/gui/elements/object.py index 0132b9a..428edc1 100644 --- a/gui/elements/object.py +++ b/gui/elements/object.py @@ -9,7 +9,7 @@ import driver from gui import objects_map from scripts.tools.image import Image -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class QObject: @@ -110,17 +110,17 @@ class QObject: y or self.height // 2, button or driver.Qt.LeftButton ) - _logger.info(f'{self}: clicked') + LOG.info(f'{self}: clicked') @allure.step('Hover {0}') def hover(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): def _hover(): try: driver.mouseMove(self.object) - _logger.info(f'{self}: mouse hovered') + LOG.info(f'{self}: mouse hovered') return getattr(self.object, 'hovered', True) except RuntimeError as err: - _logger.debug(err) + LOG.debug(err) time.sleep(1) return False @@ -138,18 +138,18 @@ class QObject: y or self.height // 2, driver.Qt.RightButton ) - _logger.info(f'{self}: clicked via Right Mouse Button') + LOG.info(f'{self}: clicked via Right Mouse Button') @allure.step('Wait until appears {0}') def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): assert driver.waitFor(lambda: self.is_visible, timeout_msec), f'Object {self} is not visible' - _logger.info(f'{self}: is visible') + LOG.info(f'{self}: is visible') return self @allure.step('Wait until hidden {0}') def wait_until_hidden(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): assert driver.waitFor(lambda: not self.is_visible, timeout_msec), f'Object {self} is not hidden' - _logger.info(f'{self}: is hidden') + LOG.info(f'{self}: is hidden') @classmethod def wait_for(cls, condition, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC) -> bool: diff --git a/gui/elements/scroll.py b/gui/elements/scroll.py index db817fb..5a8cced 100644 --- a/gui/elements/scroll.py +++ b/gui/elements/scroll.py @@ -6,7 +6,7 @@ import allure import driver from .object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class Scroll(QObject): @@ -29,9 +29,9 @@ class Scroll(QObject): if hasattr(element.object, 'height'): y += int(element.object.height) driver.flick(self.object, 0, y) - _logger.info(f'{self}: scrolled to {element}') + LOG.info(f'{self}: scrolled to {element}') except LookupError as err: - _logger.debug(err) + LOG.debug(err) @allure.step('Scroll down to object') def vertical_down_to(self, element: QObject, timeout_sec: int = 5): @@ -41,4 +41,4 @@ class Scroll(QObject): driver.flick(self.object, 0, step) if time.monotonic() - started_at > timeout_sec: raise LookupError(f'Object not found: {element}') - _logger.info(f'{self}: scrolled down to {element}') + LOG.info(f'{self}: scrolled down to {element}') diff --git a/gui/elements/slider.py b/gui/elements/slider.py index 4a9de31..ebc2388 100644 --- a/gui/elements/slider.py +++ b/gui/elements/slider.py @@ -3,7 +3,7 @@ import allure from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class Slider(QObject): @@ -34,4 +34,4 @@ class Slider(QObject): if self.value > value: while self.value > value: self.object.decrease() - _logger.info(f'{self}: value changed to "{value}"') + LOG.info(f'{self}: value changed to "{value}"') diff --git a/gui/elements/text_edit.py b/gui/elements/text_edit.py index 67e24df..fabc03a 100644 --- a/gui/elements/text_edit.py +++ b/gui/elements/text_edit.py @@ -6,7 +6,7 @@ import configs import driver from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class TextEdit(QObject): @@ -27,7 +27,7 @@ class TextEdit(QObject): @allure.step('Type: {1} in {0}') def type_text(self, value: str): driver.type(self.object, value) - _logger.info(f'{self}: value changed to "{value}"') + LOG.info(f'{self}: value changed to "{value}"') return self @allure.step('Clear {0}') @@ -36,5 +36,5 @@ class TextEdit(QObject): if verify: assert driver.waitFor(lambda: not self.text), \ f'Clear text field failed, value in field: "{self.text}"' - _logger.info(f'{self}: cleared') + LOG.info(f'{self}: cleared') return self diff --git a/gui/elements/text_label.py b/gui/elements/text_label.py index 4cc93e3..70cf11f 100644 --- a/gui/elements/text_label.py +++ b/gui/elements/text_label.py @@ -4,7 +4,7 @@ import allure from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class TextLabel(QObject): diff --git a/gui/elements/window.py b/gui/elements/window.py index f6d350f..bb70f1c 100644 --- a/gui/elements/window.py +++ b/gui/elements/window.py @@ -6,7 +6,7 @@ import configs import driver from gui.elements.object import QObject -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class Window(QObject): @@ -20,39 +20,39 @@ class Window(QObject): @allure.step("Maximize {0}") def maximize(self): assert driver.toplevel_window.maximize(self.real_name), 'Maximize failed' - _logger.info(f'Window {getattr(self.object, "title", "")} is maximized') + LOG.info(f'Window {getattr(self.object, "title", "")} is maximized') @allure.step("Minimize {0}") def minimize(self): assert driver.toplevel_window.minimize(self.real_name), 'Minimize failed' - _logger.info(f'Window {getattr(self.object, "title", "")} is minimized') + LOG.info(f'Window {getattr(self.object, "title", "")} is minimized') @allure.step("Set focus on {0}") def set_focus(self): assert driver.toplevel_window.set_focus(self.real_name), 'Set focus failed' - _logger.info(f'Window {getattr(self.object, "title", "")} in focus') + LOG.info(f'Window {getattr(self.object, "title", "")} in focus') @allure.step("Move {0} on top") def on_top_level(self): assert driver.toplevel_window.on_top_level(self.real_name), 'Set on top failed' - _logger.info(f'Window {getattr(self.object, "title", "")} moved on top') + LOG.info(f'Window {getattr(self.object, "title", "")} moved on top') @allure.step("Close {0}") def close(self): driver.toplevel_window.close(self.real_name) - _logger.info(f'{self} closed') + LOG.info(f'{self} closed') @allure.step("Show {0}") def show(self): driver.waitForObjectExists(self.real_name).setVisible(True) - _logger.info(f'{self} is visible') + LOG.info(f'{self} is visible') @allure.step("Hide {0}") def hide(self): driver.waitForObjectExists(self.real_name).setVisible(False) - _logger.info(f'{self} hidden') + LOG.info(f'{self} hidden') def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): super().wait_until_appears(timeout_msec) - _logger.info(f'Window {getattr(self.object, "title", "")} appears') + LOG.info(f'Window {getattr(self.object, "title", "")} appears') return self diff --git a/gui/main_window.py b/gui/main_window.py index a189e52..d7d0bc5 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -25,7 +25,7 @@ from gui.screens.settings import SettingsScreen from gui.screens.wallet import WalletScreen from scripts.tools.image import Image -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class LeftPanel(QObject): diff --git a/gui/screens/onboarding.py b/gui/screens/onboarding.py index b2de68e..9cdbd95 100755 --- a/gui/screens/onboarding.py +++ b/gui/screens/onboarding.py @@ -20,7 +20,7 @@ from gui.elements.text_label import TextLabel from scripts.tools.image import Image from scripts.utils.system_path import SystemPath -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class AllowNotificationsView(QObject): diff --git a/gui/screens/settings_communities.py b/gui/screens/settings_communities.py index 0a88a51..b2aafa8 100644 --- a/gui/screens/settings_communities.py +++ b/gui/screens/settings_communities.py @@ -13,7 +13,7 @@ from gui.elements.object import QObject from gui.elements.text_label import TextLabel from gui.screens.community_settings import CommunitySettingsScreen -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class CommunitiesSettingsView(QObject): @@ -43,7 +43,7 @@ class CommunitiesSettingsView(QObject): try: members = self._community_template_members.text except LookupError as err: - _logger.info(err) + LOG.info(err) members = 0 image = self._community_template_image.image diff --git a/scripts/tools/image.py b/scripts/tools/image.py index baf8520..03339da 100755 --- a/scripts/tools/image.py +++ b/scripts/tools/image.py @@ -16,7 +16,7 @@ from configs.system import IS_LIN from scripts.tools.ocv import Ocv from scripts.utils.system_path import SystemPath -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class Image: @@ -53,7 +53,7 @@ class Image: @allure.step('Grab image view from object') def update_view(self): - _logger.debug(f'Image view was grab from: {self.object_name}') + LOG.debug(f'Image view was grab from: {self.object_name}') rect = driver.object.globalBounds(driver.waitForObject(self.object_name)) img = ImageGrab.grab( bbox=(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height), @@ -77,10 +77,10 @@ class Image: self.update_view() correlation = Ocv.compare_images(self.view, expected) result = correlation >= threshold - _logger.info(f'Images equals on: {abs(round(correlation, 4) * 100)}%') + LOG.info(f'Images equals on: {abs(round(correlation, 4) * 100)}%') if result: - _logger.info(f'Screenshot comparison passed') + LOG.info(f'Screenshot comparison passed') else: configs.testpath.TEST_ARTIFACTS.mkdir(parents=True, exist_ok=True) diff = Ocv.draw_contours(self.view, expected) @@ -97,7 +97,7 @@ class Image: allure.attach(name='expected', body=expected_fp.read_bytes(), attachment_type=allure.attachment_type.PNG) allure.attach(name='diff', body=diff_fp.read_bytes(), attachment_type=allure.attachment_type.PNG) - _logger.info( + LOG.info( f"Screenshot comparison failed.\n" f"Actual, Diff and Expected screenshots are saved:\n" f"{configs.testpath.TEST_ARTIFACTS.relative_to(configs.testpath.ROOT)}.") @@ -112,7 +112,7 @@ class Image: @allure.step('Parse text on image') def to_string(self, custom_config: str): text: str = pytesseract.image_to_string(self.view, config=custom_config) - _logger.debug(f'Text on image: {text}') + LOG.debug(f'Text on image: {text}') return text @allure.step('Verify: Image contains text: {1}') @@ -227,8 +227,8 @@ def compare(actual: Image, if (datetime.now() - start).seconds > timout_sec: if configs.UPDATE_VP_ON_FAIL and expected_fp is not None: actual.save(expected_fp, force=True) - _logger.warning(f'VP file updated: {expected_fp}') + LOG.warning(f'VP file updated: {expected_fp}') break else: raise AssertionError('Images comparison failed') - _logger.info(f'Screenshot comparison passed') + LOG.info(f'Screenshot comparison passed') diff --git a/scripts/utils/system_path.py b/scripts/utils/system_path.py index f8516f8..fbb28a2 100644 --- a/scripts/utils/system_path.py +++ b/scripts/utils/system_path.py @@ -5,7 +5,7 @@ import shutil import allure -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) class SystemPath(pathlib.Path): diff --git a/tests/onboarding/test_onboarding_generate_new_keys.py b/tests/onboarding/test_onboarding_generate_new_keys.py index 51e0609..30e74a9 100755 --- a/tests/onboarding/test_onboarding_generate_new_keys.py +++ b/tests/onboarding/test_onboarding_generate_new_keys.py @@ -12,7 +12,7 @@ from gui.components.picture_edit_popup import shift_image from gui.components.splash_screen import SplashScreen from gui.screens.onboarding import AllowNotificationsView, WelcomeToStatusView, BiometricsView, KeysView -_logger = logging.getLogger(__name__) +LOG = logging.getLogger(__name__) @pytest.fixture