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

[1LP][RFR] Automate test: Create schedule for base report #7904

Merged
merged 4 commits into from Oct 24, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions cfme/intelligence/reports/reports.py
Expand Up @@ -11,6 +11,7 @@
from widgetastic_manageiq.expression_editor import ExpressionEditor
from widgetastic_patternfly import Button, Input, BootstrapSelect, Tab, CandidateNotFound

from cfme.intelligence.reports.schedules import SchedulesFormCommon
from cfme.modeling.base import BaseCollection, BaseEntity
from cfme.utils import ParamClassName
from cfme.utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to
Expand Down Expand Up @@ -225,6 +226,24 @@ def is_displayed(self):
)


class ReportScheduleView(SchedulesFormCommon):
mshriver marked this conversation as resolved.
Show resolved Hide resolved
add_button = Button("Add")

@property
def is_displayed(self):
report_obj = self.context["object"]
return (
self.in_intel_reports
and self.title.text == "Adding a new Schedule"
and self.reports.tree.currently_selected
== [
"All Reports",
report_obj.type,
report_obj.subtype,
report_obj.menu_name,
]
)

@attr.s
class Report(BaseEntity, Updateable):
_param_name = ParamClassName('title')
Expand Down Expand Up @@ -312,6 +331,42 @@ def delete(self, cancel=False):
def saved_reports(self):
return self.collections.saved_reports

def create_schedule(self, name=None, description=None, active=None,
mshriver marked this conversation as resolved.
Show resolved Hide resolved
timer=None, emails=None, email_options=None):

view = navigate_to(self, "ScheduleReport")
view.fill({
"name": name,
"description": description,
"active": active,
"run": timer.get("run"),
"time_zone": timer.get("time_zone"),
"starting_date": timer.get("starting_date"),
"hour": timer.get("hour"),
"minute": timer.get("minute"),
"emails_send": bool(emails),
"emails": emails,
"send_if_empty": email_options.get("send_if_empty"),
"send_txt": email_options.get("send_txt"),
"send_csv": email_options.get("send_csv"),
"send_pdf": email_options.get("send_pdf")
})

view.add_button.click()
view.flash.assert_no_error()

schedule = self.appliance.collections.schedules.instantiate(
name=name or self.menu_name,
mshriver marked this conversation as resolved.
Show resolved Hide resolved
description=description,
filter=(self.company_name, self.subtype, self.menu_name),
active=active,
emails=emails,
email_options=email_options,
)

assert schedule.exists
return schedule

def queue(self, wait_for_finish=False):
view = navigate_to(self, "Details")
view.report_info.queue_button.click()
Expand Down Expand Up @@ -556,6 +611,20 @@ def step(self):
self.view.report_info.select()


@navigator.register(Report, "ScheduleReport")
class ReportSchedule(CFMENavigateStep):
VIEW = ReportScheduleView
prerequisite = NavigateToAttribute("appliance.server", "CloudIntelReports")

def step(self):
self.prerequisite_view.reports.tree.click_path(
"All Reports",
self.obj.type or self.obj.company_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am suspect about these or. are those required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is required to navigate to the details page of the report and then select Add a new Schedule from the configuration menu.

self.obj.subtype or "Custom",
self.obj.menu_name
)
self.prerequisite_view.configuration.item_select("Add a new Schedule")

@navigator.register(SavedReport, "Details")
class SavedReportDetails(CFMENavigateStep):
VIEW = SavedReportDetailsView
Expand Down
24 changes: 23 additions & 1 deletion cfme/tests/intelligence/reports/test_crud.py
Expand Up @@ -4,7 +4,6 @@
import yaml

from cfme import test_requirements
from cfme.intelligence.reports.schedules import ScheduleCollection
from cfme.intelligence.reports.widgets import AllDashboardWidgetsView
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.blockers import BZ
Expand Down Expand Up @@ -264,3 +263,26 @@ def test_reports_delete_saved_report(appliance, request):
view.configuration.item_select(
item='Delete selected Saved Reports', handle_alert=True)
assert not report.exists


def test_reports_crud_schedule_for_base_report_once(appliance, request):
mshriver marked this conversation as resolved.
Show resolved Hide resolved
report = appliance.collections.reports.instantiate(
type="Configuration Management",
subtype="Virtual Machines",
menu_name="Hardware Information for VMs",
)
data = {
"timer": {"hour": "12", "minute": "10"},
"emails": "test@example.com",
"email_options": {
"send_if_empty": True,
"send_pdf": True,
"send_csv": True,
"send_txt": True,
},
}
schedule = report.create_schedule(**data)

assert schedule.enabled
schedule.delete(cancel=False)
assert not schedule.exists