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

Commit

Permalink
Merge pull request #8214 from valaparthvi/invalid_email_test
Browse files Browse the repository at this point in the history
[1LP][RFR]New Test to validate emails in schedules and add a new attribute to `Schedule`
  • Loading branch information
izapolsk committed Dec 5, 2018
2 parents 5b96565 + a23b3d2 commit 09ad8f2
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cfme/intelligence/reports/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def saved_reports(self):
return self.collections.saved_reports

def create_schedule(self, name=None, description=None, active=None,
timer=None, emails=None, email_options=None):
timer=None, from_email=None, emails=None, email_options=None):

view = navigate_to(self, "ScheduleReport")
view.fill({
Expand All @@ -349,6 +349,7 @@ def create_schedule(self, name=None, description=None, active=None,
"hour": timer.get("hour"),
"minute": timer.get("minute"),
"emails_send": bool(emails),
"from_email": from_email,
"emails": emails,
"send_if_empty": email_options.get("send_if_empty"),
"send_txt": email_options.get("send_txt"),
Expand Down
5 changes: 4 additions & 1 deletion cfme/intelligence/reports/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SchedulesFormCommon(CloudIntelReportsView):
minute = BootstrapSelect("start_min")
# Email
emails_send = Checkbox("send_email_cb")
from_email = TextInput(name="from")
emails = AlertEmail()
send_if_empty = Checkbox("send_if_empty")
send_txt = Checkbox("send_txt")
Expand Down Expand Up @@ -135,6 +136,7 @@ def __str__(self):
filter = attr.ib()
active = attr.ib(default=None)
timer = attr.ib(default=None)
from_email = attr.ib(default=None)
emails = attr.ib(default=None)
email_options = attr.ib(default=None)

Expand Down Expand Up @@ -193,7 +195,7 @@ class ScheduleCollection(BaseCollection):
ENTITY = Schedule

def create(self, name=None, description=None, filter=None, active=None,
timer=None, emails=None, email_options=None):
timer=None, from_email=None, emails=None, email_options=None):
schedule = self.instantiate(name, description, filter, active=active, timer=timer,
emails=emails, email_options=email_options)
view = navigate_to(self, "Add")
Expand All @@ -210,6 +212,7 @@ def create(self, name=None, description=None, filter=None, active=None,
"hour": timer.get("hour"),
"minute": timer.get("minute"),
"emails_send": bool(emails),
"from_email": from_email,
"emails": emails,
"send_if_empty": email_options.get("send_if_empty"),
"send_txt": email_options.get("send_txt"),
Expand Down
12 changes: 12 additions & 0 deletions cfme/tests/intelligence/reports/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import yaml

from cfme import test_requirements
from cfme.intelligence.reports.schedules import NewScheduleView
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 @@ -309,3 +310,14 @@ def test_crud_custom_report_schedule(
custom_report_schedule = appliance.collections.schedules.create(**schedule_data)
assert custom_report_schedule.exists
custom_report_schedule.delete(cancel=False)


@pytest.mark.ignore_stream('5.9')
def test_report_schedules_invalid_email(appliance, schedule_data):
schedule_data["emails"] = (fauxfactory.gen_alpha(), fauxfactory.gen_alpha())
schedule_data["from_email"] = fauxfactory.gen_alpha()
with pytest.raises(AssertionError):
appliance.collections.schedules.create(**schedule_data)
view = appliance.collections.schedules.create_view(NewScheduleView)
view.flash.assert_message("One of e-mail addresses 'To' is not valid")
view.flash.assert_message("E-mail address 'From' is not valid")
1 change: 1 addition & 0 deletions data/schedules_crud/basic01.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down
1 change: 1 addition & 0 deletions data/schedules_report/daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down
1 change: 1 addition & 0 deletions data/schedules_report/hourly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down
1 change: 1 addition & 0 deletions data/schedules_report/monthly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down
1 change: 1 addition & 0 deletions data/schedules_report/once.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down
1 change: 1 addition & 0 deletions data/schedules_report/weekly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ timer:
emails:
- test1@example.test
- test2@example.test
from_email: sender@example.test
email_options:
send_if_empty: True
send_txt: True
Expand Down

0 comments on commit 09ad8f2

Please sign in to comment.