Improve stability of horizon_host_inventory sanity test
- Updated asserts to validate_equals - Improved stability of getting the edit_host_button_text Change-Id: I5267e78ccf5e74be8cc674bf4f52885a47fe427d
This commit is contained in:
@ -273,7 +273,7 @@ def test_horizon_host_inventory_display_active_controller(request):
|
||||
|
||||
# Validate the Headers of the Controller Table
|
||||
all_controller_headers = host_inventory.get_controller_hosts_table_headers()
|
||||
assert len(all_controller_headers) == 8, "There should be exactly 8 table headers"
|
||||
validate_equals(len(all_controller_headers), 8, "There should be exactly 8 table headers")
|
||||
assert all_controller_headers[0], "Host Name header is missing."
|
||||
assert all_controller_headers[1], "Personality header is missing."
|
||||
assert all_controller_headers[2], "Admin State header is missing."
|
||||
@ -292,28 +292,21 @@ def test_horizon_host_inventory_display_active_controller(request):
|
||||
|
||||
# Compare the values in the active controller in the Host Inventory table with the output of system host-list.
|
||||
horizon_host_information = host_inventory.get_controller_host_information(active_host_name)
|
||||
assert (
|
||||
active_controller_output.get_host_name().lower() == horizon_host_information.get_host_name().lower()
|
||||
), f"Host Name mismatch. Expecting: {active_controller_output.get_host_name().lower()}, Observed: {horizon_host_information.get_host_name().lower()}"
|
||||
assert "Controller-Active" == horizon_host_information.get_personality(), f"Expecting Personality: Controller-Active, Observed: {horizon_host_information.get_personality()}"
|
||||
assert (
|
||||
active_controller_output.get_administrative().lower() == horizon_host_information.get_admin_state().lower()
|
||||
), f"Admin State mismatch. Expecting: {active_controller_output.get_administrative().lower()}, Observed: {horizon_host_information.get_admin_state().lower()}"
|
||||
assert (
|
||||
active_controller_output.get_operational().lower() == horizon_host_information.get_operational_state().lower()
|
||||
), f"Operational State mismatch. Expecting: {active_controller_output.get_operational().lower()}, Observed: {horizon_host_information.get_operational_state().lower()}"
|
||||
assert (
|
||||
active_controller_output.get_availability().lower() == horizon_host_information.get_availability_state().lower()
|
||||
), f"Availability State mismatch. Expecting: {active_controller_output.get_availability().lower()}, Observed: {horizon_host_information.get_availability_state().lower()}"
|
||||
validate_equals(horizon_host_information.get_host_name().lower(), active_controller_output.get_host_name().lower(), "Host Name of active controller")
|
||||
validate_equals(horizon_host_information.get_personality(),"Controller-Active", "Personality of active controller")
|
||||
validate_equals(horizon_host_information.get_admin_state().lower(), active_controller_output.get_administrative().lower(), "Admin State of active controller")
|
||||
validate_equals(horizon_host_information.get_operational_state().lower(), active_controller_output.get_operational().lower(), "Operational State of active controller")
|
||||
validate_equals(horizon_host_information.get_availability_state().lower(), active_controller_output.get_availability().lower(), "Availability State of active controller")
|
||||
|
||||
assert (
|
||||
'minute' in horizon_host_information.get_uptime()
|
||||
or 'hour' in horizon_host_information.get_uptime()
|
||||
or 'day' in horizon_host_information.get_uptime()
|
||||
or 'week' in horizon_host_information.get_uptime()
|
||||
), f"Uptime doesn't follow the expected format '* weeks, * days, * hours, * minutes'. Observed: {horizon_host_information.get_uptime()}"
|
||||
assert horizon_host_information.get_status() is None, "Status Column should be empty."
|
||||
assert horizon_host_information.get_actions() == "Edit Host", f"Actions button should have a label of 'Edit Host' - Observed: {horizon_host_information.get_actions()}"
|
||||
|
||||
validate_equals(horizon_host_information.get_status(), None, "Status Column of active controller")
|
||||
validate_equals(host_inventory.get_controller_edit_host_button_text(active_host_name), "Edit Host", "Label of Edit Host button")
|
||||
get_logger().log_info("Validated the the table entries for the Active Controller")
|
||||
|
||||
|
||||
|
@ -51,3 +51,13 @@ class HorizonHostInventoryPage(BasePage):
|
||||
|
||||
horizon_host_object = HorizonHostObject(row_info_list)
|
||||
return horizon_host_object
|
||||
|
||||
def get_controller_edit_host_button_text(self, host_name: str) -> bool:
|
||||
"""
|
||||
This function validates that the 'Edit Host' button is displayed for the specified controller host.
|
||||
|
||||
Returns: bool
|
||||
"""
|
||||
edit_button_locator = self.locators.get_locator_controller_table_edit_host_button(host_name)
|
||||
edit_button_text = self.driver.get_text(edit_button_locator)
|
||||
return edit_button_text
|
||||
|
@ -15,7 +15,7 @@ class HorizonHostInventoryPageLocators:
|
||||
"""
|
||||
return WebLocator("#hostscontroller th:not(.hidden)", By.CSS_SELECTOR)
|
||||
|
||||
def get_locator_controller_table_row_information(self, host_name: str):
|
||||
def get_locator_controller_table_row_information(self, host_name: str) -> WebLocator:
|
||||
"""
|
||||
Locator which allows us to find all the row information associated with the host_name passed in.
|
||||
Args:
|
||||
@ -26,6 +26,17 @@ class HorizonHostInventoryPageLocators:
|
||||
"""
|
||||
return WebLocator(f"tr[id*='hostscontroller'][ data-display='{host_name}'] td:not(.hidden)", By.CSS_SELECTOR)
|
||||
|
||||
def get_locator_controller_table_edit_host_button(self, host_name: str) -> WebLocator:
|
||||
"""
|
||||
Locator which allows us to find the 'Edit Host' button associated with the specified controller host_name.
|
||||
Args:
|
||||
host_name: Name of the host for which we want to find the Edit Host button.
|
||||
|
||||
Returns: A Locator
|
||||
|
||||
"""
|
||||
return WebLocator(f"tr[id*='hostscontroller'][ data-display='{host_name}'] a[id*='action_update']", By.CSS_SELECTOR)
|
||||
|
||||
def get_locator_worker_table_displayed_headers(self) -> WebLocator:
|
||||
"""
|
||||
Locator for the list of visible table headers of the Worker Hosts table.
|
||||
|
@ -23,7 +23,7 @@ class HorizonHostObject:
|
||||
self.availability_state = row_values_list[4]
|
||||
self.uptime = row_values_list[5]
|
||||
self.status = row_values_list[6]
|
||||
self.actions = row_values_list[7]
|
||||
# row_values_list[7] is the Actions button, which needs to be handled separately
|
||||
|
||||
def get_host_name(self) -> str:
|
||||
"""
|
||||
@ -80,11 +80,3 @@ class HorizonHostObject:
|
||||
|
||||
"""
|
||||
return self.status
|
||||
|
||||
def get_actions(self) -> str:
|
||||
"""
|
||||
Getter for the actions
|
||||
Returns:
|
||||
|
||||
"""
|
||||
return self.actions
|
||||
|
Reference in New Issue
Block a user