From 9e63b10b8b1a001c718f527f44e239f460dbbe97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 4 Dec 2023 19:16:52 +0100 Subject: [PATCH] chore(all) rename _logger to LOG to match refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to: https://github.com/status-im/desktop-qa-automation/pull/352 Signed-off-by: Jakub SokoĊ‚owski --- fixtures/path.py | 2 +- gui/elements/button.py | 2 +- gui/elements/check_box.py | 2 +- gui/elements/object.py | 12 ++++++------ gui/elements/scroll.py | 6 +++--- gui/elements/slider.py | 2 +- gui/elements/text_edit.py | 4 ++-- gui/elements/window.py | 20 ++++++++++++-------- 8 files changed, 27 insertions(+), 23 deletions(-) diff --git a/fixtures/path.py b/fixtures/path.py index 199d000..72efecf 100644 --- a/fixtures/path.py +++ b/fixtures/path.py @@ -20,7 +20,7 @@ def generate_test_data(request): configs.testpath.TEST_ARTIFACTS.relative_to(configs.testpath.ROOT)) LOG.debug('Verification points directory: %s', configs.testpath.TEST_VP.relative_to(configs.testpath.ROOT)) - LOG.info(f'Start test: {test_name}') + LOG.info('Start test: %s', test_name) def generate_test_info(node): diff --git a/gui/elements/button.py b/gui/elements/button.py index 7ae1191..aed19c6 100644 --- a/gui/elements/button.py +++ b/gui/elements/button.py @@ -20,6 +20,6 @@ class Button(QObject): ): if None not in (x, y, button): getattr(self.object, 'clicked')() - LOG.info(f'{self}: clicked') + LOG.info('%s: clicked', self) else: super(Button, self).click(x, y, button) diff --git a/gui/elements/check_box.py b/gui/elements/check_box.py index 6461606..bf1125a 100644 --- a/gui/elements/check_box.py +++ b/gui/elements/check_box.py @@ -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' - LOG.info(f'{self}: value changed to "{value}"') + LOG.info('%s: value changed to "%s"', self, value) diff --git a/gui/elements/object.py b/gui/elements/object.py index 428edc1..b499337 100644 --- a/gui/elements/object.py +++ b/gui/elements/object.py @@ -110,17 +110,17 @@ class QObject: y or self.height // 2, button or driver.Qt.LeftButton ) - LOG.info(f'{self}: clicked') + LOG.info('%s: clicked', self) @allure.step('Hover {0}') def hover(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): def _hover(): try: driver.mouseMove(self.object) - LOG.info(f'{self}: mouse hovered') + LOG.info('%s: mouse hovered', self) return getattr(self.object, 'hovered', True) except RuntimeError as err: - LOG.debug(err) + LOG.error(err) time.sleep(1) return False @@ -138,18 +138,18 @@ class QObject: y or self.height // 2, driver.Qt.RightButton ) - LOG.info(f'{self}: clicked via Right Mouse Button') + LOG.info('%s: clicked via Right Mouse Button', self) @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' - LOG.info(f'{self}: is visible') + LOG.info('%s: is visible', self) 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' - LOG.info(f'{self}: is hidden') + LOG.info('%s: is hidden', self) @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 5a8cced..004c825 100644 --- a/gui/elements/scroll.py +++ b/gui/elements/scroll.py @@ -29,9 +29,9 @@ class Scroll(QObject): if hasattr(element.object, 'height'): y += int(element.object.height) driver.flick(self.object, 0, y) - LOG.info(f'{self}: scrolled to {element}') + LOG.info('%s: scrolled to %s', self, element) except LookupError as err: - LOG.debug(err) + LOG.error(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}') - LOG.info(f'{self}: scrolled down to {element}') + LOG.info('%s: scrolled down to %s', self, element) diff --git a/gui/elements/slider.py b/gui/elements/slider.py index ebc2388..b4771cf 100644 --- a/gui/elements/slider.py +++ b/gui/elements/slider.py @@ -34,4 +34,4 @@ class Slider(QObject): if self.value > value: while self.value > value: self.object.decrease() - LOG.info(f'{self}: value changed to "{value}"') + LOG.debug('%s: value changed to "%s"', self, value) diff --git a/gui/elements/text_edit.py b/gui/elements/text_edit.py index fabc03a..028d727 100644 --- a/gui/elements/text_edit.py +++ b/gui/elements/text_edit.py @@ -27,7 +27,7 @@ class TextEdit(QObject): @allure.step('Type: {1} in {0}') def type_text(self, value: str): driver.type(self.object, value) - LOG.info(f'{self}: value changed to "{value}"') + LOG.info('%s: value changed to "%s"', self, 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}"' - LOG.info(f'{self}: cleared') + LOG.info('%s: cleared', self) return self diff --git a/gui/elements/window.py b/gui/elements/window.py index bb70f1c..734443d 100644 --- a/gui/elements/window.py +++ b/gui/elements/window.py @@ -17,42 +17,46 @@ class Window(QObject): self.on_top_level() return self + @property + def title(self): + return str(getattr(self.object, 'title', '')) + @allure.step("Maximize {0}") def maximize(self): assert driver.toplevel_window.maximize(self.real_name), 'Maximize failed' - LOG.info(f'Window {getattr(self.object, "title", "")} is maximized') + LOG.info('Window %s was maximized', self.title) @allure.step("Minimize {0}") def minimize(self): assert driver.toplevel_window.minimize(self.real_name), 'Minimize failed' - LOG.info(f'Window {getattr(self.object, "title", "")} is minimized') + LOG.info('Window %s was minimized', self.title) @allure.step("Set focus on {0}") def set_focus(self): assert driver.toplevel_window.set_focus(self.real_name), 'Set focus failed' - LOG.info(f'Window {getattr(self.object, "title", "")} in focus') + LOG.info('Window %s was focused', self.title) @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' - LOG.info(f'Window {getattr(self.object, "title", "")} moved on top') + LOG.info('Window %s moved on top', self.title) @allure.step("Close {0}") def close(self): driver.toplevel_window.close(self.real_name) - LOG.info(f'{self} closed') + LOG.info('%s closed', self) @allure.step("Show {0}") def show(self): driver.waitForObjectExists(self.real_name).setVisible(True) - LOG.info(f'{self} is visible') + LOG.info('%s is visible', self) @allure.step("Hide {0}") def hide(self): driver.waitForObjectExists(self.real_name).setVisible(False) - LOG.info(f'{self} hidden') + LOG.info('%s hidden', self) def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): super().wait_until_appears(timeout_msec) - LOG.info(f'Window {getattr(self.object, "title", "")} appears') + LOG.info('Window %s appears', self.title) return self