-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for config_report (#791)
Signed-off-by: Adarsh Dubey <addubey@redhat.com> Signed-off-by: Adarsh Dubey <addubey@redhat.com>
- Loading branch information
1 parent
9e93ca1
commit 6d34bcd
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |