From f5a350f5a371681e524d71e250c1637e8597f54d Mon Sep 17 00:00:00 2001 From: Vladimir Sedmik Date: Wed, 22 Jan 2025 17:25:04 +0100 Subject: [PATCH] extend sync_status page with active_only support --- airgun/entities/sync_status.py | 19 +++++---- airgun/views/sync_status.py | 75 +++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/airgun/entities/sync_status.py b/airgun/entities/sync_status.py index 0c7862805..d213155e7 100644 --- a/airgun/entities/sync_status.py +++ b/airgun/entities/sync_status.py @@ -9,16 +9,18 @@ class SyncStatusEntity(BaseEntity): endpoint_path = '/katello/sync_management' - def read(self, widget_names=None): + def read(self, widget_names=None, active_only=False): """Read all widgets at Sync status entity""" view = self.navigate_to(self, 'All') + view.active_only.fill(active_only) return view.read(widget_names=widget_names) - def synchronize(self, repository_paths, timeout=3600): + def synchronize(self, repository_paths, synchronous=True, timeout=3600): """Synchronize repositories :param repository_paths: A list of repositories to synchronize where each element of the list is path to repository represented by a list or tuple. + :param synchrounous: bool if to wait for all repos sync, defaults to True. :param timeout: time to wait for all repositories to be synchronized. Usage:: @@ -38,12 +40,13 @@ def synchronize(self, repository_paths, timeout=3600): for repo_node in repo_nodes: repo_node.fill(True) view.synchronize_now.click() - wait_for( - lambda: all(node.progress is None for node in repo_nodes), - timeout=timeout, - delay=5, - logger=view.logger, - ) + if synchronous: + wait_for( + lambda: all(node.progress is None for node in repo_nodes), + timeout=timeout, + delay=5, + logger=view.logger, + ) return [node.result for node in repo_nodes] diff --git a/airgun/views/sync_status.py b/airgun/views/sync_status.py index 8fa566d0c..43f87d93b 100644 --- a/airgun/views/sync_status.py +++ b/airgun/views/sync_status.py @@ -58,6 +58,11 @@ def is_child_of(self, node): """Return whether this node is a child of node""" return f'child-of-{node.id}' in self.browser.get_attribute('class', self.row) + @property + def is_displayed(self): + """Returns whether this node is displayed""" + return 'display: none' not in self.browser.get_attribute('style', self.row) + @cached_property def name(self): """Return the name of this node, the node name is the text content of @@ -132,16 +137,17 @@ def add_child(self, node): self.children[node.name] = node def read(self): - """Read this node and sub nodes if exist""" - if self.is_section: - data = {} - # ensure expanded before read - self.expand() - for child_name, child_node in self.children.items(): - data[child_name] = child_node.read() - else: - data = self.row.read() - return data + """Read this node and sub nodes if exist and displayed""" + if self.is_displayed: + if self.is_section: + data = {} + # ensure expanded before read + self.expand() + for child_name, child_node in self.children.items(): + data[child_name] = child_node.read() + else: + data = self.row.read() + return data def select(self, value): """Select or un-select if checkbox is in the row, the checkbox exist @@ -191,31 +197,32 @@ def nodes(self): last_section_node = None for row_index, row in enumerate(self): node = SyncStatusTableNode(row=row) - if node.is_root: - # Root nodes are essentially product names. - node.expand() - nodes[node.name] = node - last_section_node = node - else: - # go throw last node parents to find the parent, if that parent - # is found set it as last section parent. - parent_node = last_section_node - while parent_node: - if node.is_child_of(parent_node): - parent_node.add_child(node) - if node.is_section: - node.expand() - last_section_node = node - else: - last_section_node = parent_node - break - parent_node = parent_node.parent + if node.is_displayed: + if node.is_root: + # Root nodes are essentially product names. + node.expand() + nodes[node.name] = node + last_section_node = node else: - # We have not found a parent for this node, - # this has not to happen, but in any case raise exception - raise ParentNodeNotFoundError( - f'Parent node for row index = {row_index} not found' - ) + # go throw last node parents to find the parent, if that parent + # is found set it as last section parent. + parent_node = last_section_node + while parent_node: + if node.is_child_of(parent_node): + parent_node.add_child(node) + if node.is_section: + node.expand() + last_section_node = node + else: + last_section_node = parent_node + break + parent_node = parent_node.parent + else: + # We have not found a parent for this node, + # this has not to happen, but in any case raise exception + raise ParentNodeNotFoundError( + f'Parent node for row index = {row_index} not found' + ) return nodes def read(self):