Skip to content

Commit

Permalink
[6.16.z] Extend sync_status page with active_only support (#1720)
Browse files Browse the repository at this point in the history
(cherry picked from commit e17a99c)

Co-authored-by: vsedmik <[email protected]>
  • Loading branch information
Satellite-QE and vsedmik authored Jan 27, 2025
1 parent 7af8d73 commit 1a84aa6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 42 deletions.
19 changes: 11 additions & 8 deletions airgun/entities/sync_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -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]

Expand Down
75 changes: 41 additions & 34 deletions airgun/views/sync_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 1a84aa6

Please sign in to comment.