Перенесено в компонент verify_json_container_content
parent
3417feb4be
commit
e922bc9237
|
|
@ -8,6 +8,8 @@ import re
|
|||
from playwright.sync_api import Page
|
||||
from tools.logger import get_logger
|
||||
from components.modal_window_component import ModalWindowComponent
|
||||
from components.json_container_component import JsonContainerComponent
|
||||
from locators.json_container_locators import JsonContainerLocators
|
||||
|
||||
|
||||
logger = get_logger("VIEW_TEMPLATE_MODAL_WINDOW")
|
||||
|
|
@ -20,6 +22,7 @@ class ViewTemplateModalWindow(ModalWindowComponent):
|
|||
1. Инициализации модального окна с конкретным шаблоном
|
||||
2. Закрытия модального окна через тулбар
|
||||
3. Проверки содержимого модального окна
|
||||
4. Проверки содержимого JSON контейнера
|
||||
"""
|
||||
|
||||
def __init__(self, page: Page, title: str):
|
||||
|
|
@ -35,6 +38,9 @@ class ViewTemplateModalWindow(ModalWindowComponent):
|
|||
self.add_toolbar_title(self.window_title)
|
||||
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
||||
|
||||
# Инициализация JSON контейнера
|
||||
self.json_container = JsonContainerComponent(page)
|
||||
|
||||
def close_window_by_toolbar_button(self):
|
||||
"""Закрывает окно через кнопку в тулбаре."""
|
||||
self.click_toolbar_close_button()
|
||||
|
|
@ -50,3 +56,19 @@ class ViewTemplateModalWindow(ModalWindowComponent):
|
|||
self.check_by_window_title()
|
||||
self.check_toolbar_button_visibility("close")
|
||||
self.check_toolbar_button_tooltip("close", "Закрыть")
|
||||
|
||||
def verify_json_container_content(self, template_data: dict) -> None:
|
||||
"""Проверяет соответствие данных контейнера данным из API.
|
||||
|
||||
Args:
|
||||
template_data: Данные шаблона из API.
|
||||
"""
|
||||
# Читаем данные из контейнера
|
||||
actual_data = self.json_container.read_data(JsonContainerLocators.CONTAINER)
|
||||
|
||||
# Сравниваем actual_data с данными конкретного шаблона
|
||||
self.json_container.check_json_equals(
|
||||
actual_data,
|
||||
template_data,
|
||||
"Expected json content is not equal actual:"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@ from playwright.sync_api import Page
|
|||
from tools.logger import get_logger
|
||||
from locators.table_locators import TableLocators
|
||||
from locators.modal_window_locators import ModalWindowLocators
|
||||
from locators.json_container_locators import JsonContainerLocators
|
||||
from components_derived.modal_view_template import ViewTemplateModalWindow
|
||||
from components.modal_window_component import ModalWindowComponent
|
||||
from components.toolbar_component import ToolbarComponent
|
||||
from components.table_component import TableComponent
|
||||
from components.json_container_component import JsonContainerComponent
|
||||
from pages.base_page import BasePage
|
||||
|
||||
logger = get_logger("TEMPLATES_TAB")
|
||||
|
|
@ -39,8 +37,6 @@ class TemplatesTab(BasePage):
|
|||
self.templates_table = TableComponent(page)
|
||||
self.modal_windows = {}
|
||||
|
||||
self.json_container = JsonContainerComponent(page)
|
||||
|
||||
def add_modal_window(self, title: str) -> None:
|
||||
"""Добавляет модальное окно в коллекцию.
|
||||
|
||||
|
|
@ -187,6 +183,36 @@ class TemplatesTab(BasePage):
|
|||
logger.error(error_msg)
|
||||
assert False, error_msg
|
||||
|
||||
def get_template_data_from_api(self, title: str) -> dict:
|
||||
"""Получает данные шаблона из API.
|
||||
|
||||
Args:
|
||||
title: Имя шаблона.
|
||||
|
||||
Returns:
|
||||
dict: Данные шаблона из API.
|
||||
"""
|
||||
# Отправляем запрос к backend для получения информации о шаблоне
|
||||
response = self.send_get_api_request("e-cmdb/api/device/template")
|
||||
response_body = self.get_response_body(response)
|
||||
|
||||
# Извлекаем конкретный шаблон по имени из ответа API
|
||||
template_data = self.extract_specific_template(title, response_body)
|
||||
return template_data
|
||||
|
||||
def verify_json_container_content(self, title: str) -> None:
|
||||
"""Проверяет соответствие данных контейнера данным из API.
|
||||
|
||||
Args:
|
||||
title: Имя шаблона для проверки.
|
||||
"""
|
||||
# Получаем данные шаблона из API
|
||||
template_data = self.get_template_data_from_api(title)
|
||||
|
||||
# Получаем модальное окно и проверяем содержимое JSON контейнера
|
||||
modal_window = self.get_modal_window(title)
|
||||
modal_window.verify_json_container_content(template_data)
|
||||
|
||||
def check_templates_modal_content(self, title: str) -> None:
|
||||
"""Проверяет наличие и корректность элементов модального окна шаблона.
|
||||
|
||||
|
|
@ -313,27 +339,3 @@ class TemplatesTab(BasePage):
|
|||
"""
|
||||
temp_modal = ModalWindowComponent(self.page)
|
||||
return temp_modal.check_window_vertical_scrolling()
|
||||
|
||||
def verify_json_container_content(self, title: str) -> None:
|
||||
"""Проверяет соответствие данных контейнера данным из API.
|
||||
|
||||
Args:
|
||||
title: Имя шаблона для проверки.
|
||||
"""
|
||||
|
||||
# Читаем данные из контейнера
|
||||
actual_data = self.json_container.read_data(JsonContainerLocators.CONTAINER)
|
||||
|
||||
# Отправляем запрос к backend для получения информации о шаблоне
|
||||
response = self.send_get_api_request("e-cmdb/api/device/template")
|
||||
response_body = self.get_response_body(response)
|
||||
|
||||
# Извлекаем конкретный шаблон по имени из ответа API
|
||||
template_data = self.extract_specific_template(title, response_body)
|
||||
|
||||
# Сравниваем actual_data с данными конкретного шаблона
|
||||
self.json_container.check_json_equals(
|
||||
actual_data,
|
||||
template_data,
|
||||
"Expected json content is not equal actual:"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue