Добавлены отсутствующие аннотации типов
parent
a3956c08fc
commit
ddcecce8b7
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import json
|
||||
import jsondiff
|
||||
from typing import Any, Dict
|
||||
from playwright.sync_api import Page
|
||||
from tools.logger import get_logger
|
||||
from components.base_component import BaseComponent
|
||||
|
|
@ -16,9 +17,6 @@ logger = get_logger("JSON_CONTAINER")
|
|||
class JsonContainerComponent(BaseComponent):
|
||||
"""Компонент для работы с JSON-данными на странице.
|
||||
|
||||
|
||||
|
||||
|
||||
Предоставляет методы чтения и проверки JSON-данных в контейнерах.
|
||||
|
||||
"""
|
||||
|
|
@ -33,7 +31,7 @@ class JsonContainerComponent(BaseComponent):
|
|||
super().__init__(page)
|
||||
|
||||
# Действия:
|
||||
def read_data(self, locator):
|
||||
def read_data(self, locator: Any) -> Dict:
|
||||
"""Читает и форматирует JSON-данные из указанного локатора.
|
||||
|
||||
Args:
|
||||
|
|
@ -93,7 +91,7 @@ class JsonContainerComponent(BaseComponent):
|
|||
return json.loads(formatted_json_string)
|
||||
|
||||
# Проверки:
|
||||
def check_json_equals(self, actual, expected, msg):
|
||||
def check_json_equals(self, actual: Any, expected: Any, msg: str) -> None:
|
||||
"""Сравнивает JSON-объекты на идентичность.
|
||||
|
||||
Args:
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class NavigationPanelComponent(BaseComponent):
|
|||
loc = self.get_locator(locator)
|
||||
loc.get_by_text(item_name).click()
|
||||
|
||||
def click_sub_item(self, node_root_locator, item_name: str) -> None:
|
||||
def click_sub_item(self, node_root_locator: str | Locator, item_name: str) -> None:
|
||||
"""Кликает по вложенному элементу с указанным текстом.
|
||||
|
||||
Args:
|
||||
|
|
@ -120,7 +120,7 @@ class NavigationPanelComponent(BaseComponent):
|
|||
found = find_and_click_item(self.page, root_locator, item_name)
|
||||
assert found, f"Navigation panel item {item_name} is missing"
|
||||
|
||||
def traverse_panel_tree(self, node_root_locator, level=0, debug=False):
|
||||
def traverse_panel_tree(self, node_root_locator: str | Locator, level=0, debug=False):
|
||||
"""
|
||||
Рекурсивно обходит дерево v-treeview и выводит информацию об элементах в режиме отладки (debug=True).
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
Содержит общие методы для взаимодействия со страницей и API.
|
||||
"""
|
||||
|
||||
from typing import Dict
|
||||
from playwright.sync_api import Page, Response, APIRequestContext, expect
|
||||
from data.environment import host
|
||||
from tools.logger import get_logger
|
||||
|
|
@ -50,7 +51,7 @@ class BasePage:
|
|||
"""Перезагружает текущую страницу."""
|
||||
self.page.reload()
|
||||
|
||||
def wait_for_timeout(self, timeout):
|
||||
def wait_for_timeout(self, timeout: int) -> None:
|
||||
"""Ожидает указанное количество миллисекунд.
|
||||
|
||||
Args:
|
||||
|
|
@ -66,7 +67,7 @@ class BasePage:
|
|||
"""
|
||||
return self.page.context.request
|
||||
|
||||
def send_get_api_request(self, uri) -> Response:
|
||||
def send_get_api_request(self, uri: str) -> Response:
|
||||
"""Отправляет GET-запрос к API.
|
||||
|
||||
Args:
|
||||
|
|
@ -84,12 +85,12 @@ class BasePage:
|
|||
)
|
||||
return response
|
||||
|
||||
def send_post_api_request(self, uri, payload) -> Response:
|
||||
def send_post_api_request(self, uri: str, payload: Dict) -> Response:
|
||||
"""Отправляет POST-запрос к API.
|
||||
|
||||
Args:
|
||||
uri (str): URI API-эндпоинта (без базового URL).
|
||||
payload: Данные для отправки в теле запроса.
|
||||
payload (Dict): Данные для отправки в теле запроса.
|
||||
|
||||
Returns:
|
||||
Response: Ответ сервера.
|
||||
|
|
@ -104,7 +105,7 @@ class BasePage:
|
|||
)
|
||||
return response
|
||||
|
||||
def get_response_body(self, response) -> dict | None:
|
||||
def get_response_body(self, response: Response) -> dict | None:
|
||||
"""Извлекает тело ответа в формате JSON.
|
||||
|
||||
Args:
|
||||
|
|
@ -180,4 +181,4 @@ class BasePage:
|
|||
return False
|
||||
return True
|
||||
|
||||
assert compare_lists(actual, expected), msg
|
||||
assert compare_lists(actual, expected), msg
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class TestUsersTab:
|
|||
user_name, _ = ut.open_edit_user_page_by_index(0)
|
||||
ut.close_edit_user_window(user_name)
|
||||
|
||||
def test_add_and_delete_user(self, browser: Page, cleanup_user) -> None:
|
||||
def test_add_and_delete_user(self, browser: Page, cleanup_user: None) -> None:
|
||||
"""Проверяет добавление и удаление пользователя.
|
||||
|
||||
Args:
|
||||
|
|
@ -181,7 +181,7 @@ class TestUsersTab:
|
|||
mp.click_subpanel_item("Пользователи")
|
||||
ut.should_not_be_user_in_table(user_data["name"], user_data["role"])
|
||||
|
||||
def test_reset_password(self, browser: Page, cleanup_autoadmin) -> None:
|
||||
def test_reset_password(self, browser: Page, cleanup_autoadmin: None) -> None:
|
||||
"""Проверяет сброс пароля пользователя.
|
||||
|
||||
Args:
|
||||
|
|
@ -221,7 +221,7 @@ class TestUsersTab:
|
|||
mp_1.click_subpanel_item("Пользователи")
|
||||
ut_1.should_not_be_user_in_table(user_data["name"], user_data["role"])
|
||||
|
||||
def test_edit_user_role(self, browser: Page, cleanup_autooperator) -> None:
|
||||
def test_edit_user_role(self, browser: Page, cleanup_autooperator: None) -> None:
|
||||
"""Проверяет изменение роли пользователя.
|
||||
|
||||
Args:
|
||||
|
|
|
|||
Loading…
Reference in New Issue