Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] Fix test: test_download_pdf #10165

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions cfme/intelligence/reports/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
from navmazing import NavigateToSibling
from widgetastic.exceptions import NoSuchElementException
from widgetastic.utils import attributize_string
from widgetastic.utils import ParametrizedLocator
from widgetastic.widget import Checkbox
from widgetastic.widget import FileInput
from widgetastic.widget import ParametrizedView
from widgetastic.widget import Select
from widgetastic.widget import Table as VanillaTable
from widgetastic.widget import Text
from widgetastic.widget import View
from widgetastic_patternfly import BootstrapSelect
from widgetastic_patternfly import Button
from widgetastic_patternfly import Dropdown
from widgetastic_patternfly import Input
from widgetastic_patternfly import SelectorDropdown

Expand All @@ -28,6 +27,7 @@
from cfme.utils.appliance.implementations.ui import CFMENavigateStep
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.appliance.implementations.ui import navigator
from cfme.utils.log import logger
from cfme.utils.pretty import Pretty
from cfme.utils.timeutil import parsetime
from cfme.utils.update import Updateable
Expand Down Expand Up @@ -228,6 +228,7 @@ class SavedReportDetailsView(CloudIntelReportsView):
# TODO: double check and raise GH to devs
paginator = PaginationPane()
view_selector = View.nested(ReportToolBarViewSelector)
download = Dropdown("Download")

@View.nested
class data_view(View): # noqa
Expand All @@ -240,22 +241,6 @@ def child_widget_accessed(self, widget):
if self.parent.view_selector.selected != "Data View":
self.parent.view_selector.select("Data View")

@ParametrizedView.nested
class download(ParametrizedView): # noqa
PARAMETERS = ("format", )
ALL_LINKS = ".//a[starts-with(@name, 'download_choice__render_report_')]"
download = Button(title="Download")
link = Text(ParametrizedLocator(".//a[normalize-space()={format|quote}]"))

def __init__(self, *args, **kwargs):
ParametrizedView.__init__(self, *args, **kwargs)
self.download.click()
self.link.click()

@classmethod
def all(cls, browser):
return [(browser.text(e), ) for e in browser.elements(cls.ALL_LINKS)]

@property
def is_displayed(self):
return (
Expand Down Expand Up @@ -631,11 +616,10 @@ def data(self):

def download(self, extension):
extensions_mapping = {"txt": "Text", "csv": "CSV", "pdf": "PDF"}
if extension == "pdf":
logger.info("PDF download is not implemented because of multiple window handling.")
view = navigate_to(self, "Details")
if self.appliance.version > '5.10' and extension == "pdf":
view.download("Print or export as {}".format(extensions_mapping[extension]))
else:
view.download("Download as {}".format(extensions_mapping[extension]))
view.download.item_select(f"Download as {extensions_mapping[extension]}")

def delete(self, cancel=False):
view = navigate_to(self, "Details")
Expand Down
9 changes: 6 additions & 3 deletions cfme/tests/intelligence/test_download_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from cfme import test_requirements
from cfme.infrastructure.provider import InfraProvider
from cfme.markers.env_markers.provider import ONE
from cfme.utils.appliance.implementations.ui import navigate_to

pytestmark = [test_requirements.report]

Expand Down Expand Up @@ -30,6 +31,8 @@ def test_download_report(setup_provider_modscope, report, filetype):
initialEstimate: 1/20h
"""
if filetype == "pdf":
# TODO: fix pdf download or create a manual test
pytest.skip("pdf printing opens a window and all the next tests fail")
report.download(filetype)
view = navigate_to(report, "Details")
# since multiple window handling is not possible, we just assert that the option is enabled.
assert view.download.item_enabled("Print or export as PDF")
else:
report.download(filetype)
7 changes: 3 additions & 4 deletions cfme/tests/networks/test_sdn_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@

def download(objecttype, extension):
view = navigate_to(objecttype, 'All')
if view.browser.product_version >= '5.10' and extension == 'pdf':
if extension == 'pdf':
view.toolbar.download.item_select("Print or export as PDF")
handle_extra_tabs(view)
else:
view.toolbar.download.item_select("Download as {}".format(extensions_mapping[extension]))
view.toolbar.download.item_select(f"Download as {extensions_mapping[extension]}")


def download_summary(spec_object):
view = navigate_to(spec_object, 'Details')
view.toolbar.download.click()
if view.browser.product_version >= '5.10':
handle_extra_tabs(view)
handle_extra_tabs(view)


def handle_extra_tabs(view):
Expand Down