Skip to content

Commit

Permalink
Adding support for config_report (#791)
Browse files Browse the repository at this point in the history
Signed-off-by: Adarsh Dubey <addubey@redhat.com>

Signed-off-by: Adarsh Dubey <addubey@redhat.com>
  • Loading branch information
adarshdubey-star authored Jan 3, 2023
1 parent 9e93ca1 commit 6d34bcd
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
70 changes: 70 additions & 0 deletions airgun/entities/config_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from airgun.entities.base import BaseEntity
from airgun.navigation import NavigateStep
from airgun.navigation import navigator
from airgun.utils import retry_navigation
from airgun.views.config_report import ConfigReportDetailsView
from airgun.views.config_report import ConfigReportsView


class ConfigReportEntity(BaseEntity):
endpoint_path = '/config_reports'

def read(self, widget_names=None, host_name=None):
"""Read all values for generated Config Reports"""
view = self.navigate_to(self, 'All')
if host_name:
view.search(host_name)
return view.read(widget_names=widget_names)

def search(self, hostname):
"""Search for specific Config report"""
view = self.navigate_to(self, 'Report Details', host_name=hostname)
return view.read()

def export(self, host_name=None):
"""Export a Config report.
:return str: path to saved file
"""
view = self.navigate_to(self, 'All')
if host_name:
view.search(host_name)
view.export.click()
return self.browser.save_downloaded_file()

def delete(self, host_name):
"""Delete a Config report"""
view = self.navigate_to(self, 'All')
view.search(host_name)
view.table.row()['Actions'].widget.click()
self.browser.handle_alert()
view.flash.assert_no_error()
view.flash.dismiss()


@navigator.register(ConfigReportEntity, 'All')
class ShowAllConfigReports(NavigateStep):
"""Navigate to all Config Report screen."""

VIEW = ConfigReportsView

@retry_navigation
def step(self, *args, **kwargs):
self.view.menu.select('Monitor', 'Config Management')


@navigator.register(ConfigReportEntity, 'Report Details')
class ConfigReportStatus(NavigateStep):
"""Navigate to Config Report details screen.
Args:host_name: name of the host to which job was applied
"""

VIEW = ConfigReportDetailsView

def prerequisite(self, *args, **kwargs):
return self.navigate_to(self.obj, 'All')

def step(self, *args, **kwargs):
self.parent.search(f'host = {kwargs.get("host_name")}')
self.parent.table.row()['Last report'].widget.click()
6 changes: 6 additions & 0 deletions airgun/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from airgun.entities.cloud_inventory import CloudInventoryEntity
from airgun.entities.computeprofile import ComputeProfileEntity
from airgun.entities.computeresource import ComputeResourceEntity
from airgun.entities.config_report import ConfigReportEntity
from airgun.entities.configgroup import ConfigGroupEntity
from airgun.entities.containerimagetag import ContainerImageTagEntity
from airgun.entities.contentcredential import ContentCredentialEntity
Expand Down Expand Up @@ -364,6 +365,11 @@ def configgroup(self):
"""Instance of Config Group entity."""
return self._open(ConfigGroupEntity)

@cached_property
def configreport(self):
"""Instance of Config Report entity."""
return self._open(ConfigReportEntity)

@cached_property
def containerimagetag(self):
"""Instance of Container Image Tags entity."""
Expand Down
35 changes: 35 additions & 0 deletions airgun/views/config_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from widgetastic.widget import Text
from widgetastic_patternfly import BreadCrumb
from widgetastic_patternfly import Button

from airgun.views.common import BaseLoggedInView
from airgun.views.common import SatTable
from airgun.views.common import SearchableViewMixin


class ConfigReportsView(BaseLoggedInView, SearchableViewMixin):
title = Text("//h1[normalize-space(.)='Reports']")
export = Button("Export")
table = SatTable(
'.//table',
column_widgets={
'Last report': Text('./a'),
'Actions': Text('.//a[@data-method="delete"]'),
},
)

@property
def is_displayed(self):
return self.browser.wait_for_element(self.title, exception=False) is not None


class ConfigReportDetailsView(BaseLoggedInView):
breadcrumb = BreadCrumb()

@property
def is_displayed(self):
breadcrumb_loaded = self.browser.wait_for_element(self.breadcrumb, exception=False)
return breadcrumb_loaded and self.breadcrumb.locations[0] == 'Config Reports'

delete = Button("Delete")
host_details = Button("Host details")

0 comments on commit 6d34bcd

Please sign in to comment.