forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(alert|report): allow null on chart and dashboard field (apache#13680
- Loading branch information
Lily Kuang
authored and
Allan Caetano de Oliveira
committed
May 21, 2021
1 parent
02b2305
commit 25443e0
Showing
2 changed files
with
56 additions
and
3 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
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 |
---|---|---|
|
@@ -496,13 +496,16 @@ def test_create_report_schedule_uniqueness(self): | |
db.session.delete(created_model) | ||
db.session.commit() | ||
|
||
@pytest.mark.usefixtures("create_report_schedules") | ||
@pytest.mark.usefixtures( | ||
"load_birth_names_dashboard_with_slices", "create_report_schedules" | ||
) | ||
def test_create_report_schedule_schema(self): | ||
""" | ||
ReportSchedule Api: Test create report schedule schema check | ||
""" | ||
self.login(username="admin") | ||
chart = db.session.query(Slice).first() | ||
dashboard = db.session.query(Dashboard).first() | ||
example_db = get_example_database() | ||
|
||
# Check that a report does not have a database reference | ||
|
@@ -590,6 +593,56 @@ def test_create_report_schedule_schema(self): | |
rv = self.client.post(uri, json=report_schedule_data) | ||
assert rv.status_code == 400 | ||
|
||
# Test that report can be created with null dashboard | ||
report_schedule_data = { | ||
"type": ReportScheduleType.ALERT, | ||
"name": "new4", | ||
"description": "description", | ||
"crontab": "0 9 * * *", | ||
"recipients": [ | ||
{ | ||
"type": ReportRecipientType.EMAIL, | ||
"recipient_config_json": {"target": "[email protected]"}, | ||
}, | ||
{ | ||
"type": ReportRecipientType.SLACK, | ||
"recipient_config_json": {"target": "channel"}, | ||
}, | ||
], | ||
"working_timeout": 3600, | ||
"chart": chart.id, | ||
"dashboard": None, | ||
"database": example_db.id, | ||
} | ||
uri = "api/v1/report/" | ||
rv = self.client.post(uri, json=report_schedule_data) | ||
assert rv.status_code == 201 | ||
|
||
# Test that report can be created with null chart | ||
report_schedule_data = { | ||
"type": ReportScheduleType.ALERT, | ||
"name": "new5", | ||
"description": "description", | ||
"crontab": "0 9 * * *", | ||
"recipients": [ | ||
{ | ||
"type": ReportRecipientType.EMAIL, | ||
"recipient_config_json": {"target": "[email protected]"}, | ||
}, | ||
{ | ||
"type": ReportRecipientType.SLACK, | ||
"recipient_config_json": {"target": "channel"}, | ||
}, | ||
], | ||
"working_timeout": 3600, | ||
"chart": None, | ||
"dashboard": dashboard.id, | ||
"database": example_db.id, | ||
} | ||
uri = "api/v1/report/" | ||
rv = self.client.post(uri, json=report_schedule_data) | ||
assert rv.status_code == 201 | ||
|
||
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices") | ||
def test_create_report_schedule_chart_dash_validation(self): | ||
""" | ||
|