betodealmeida commented on a change in pull request #15685:
URL: https://github.com/apache/superset/pull/15685#discussion_r670843038



##########
File path: superset/reports/schemas.py
##########
@@ -150,6 +156,12 @@ class ReportSchedulePostSchema(Schema):
         description=sql_description, example="SELECT value FROM 
time_series_table"
     )
     chart = fields.Integer(required=False, allow_none=True)
+    creation_method = EnumField(
+        ReportCreationMethodType,
+        by_value=True,
+        required=False,

Review comment:
       This will default to `ALERTS_REPORTS` if the field is missing, right?

##########
File path: superset/reports/schemas.py
##########
@@ -83,6 +85,10 @@
     "If an alert is staled at a working state, how long until it's state is 
reseted to"
     " error"
 )
+creation_method_description = (
+    "Creation method is used to inform the frontend whether the report/alert 
was "
+    "created in the dashboard, charts, or alerts and reports UI."

Review comment:
       ```suggestion
       "created in the dashboard, chart, or alerts and reports UI."
   ```

##########
File path: superset/models/reports.py
##########
@@ -74,6 +74,12 @@ class ReportDataFormat(str, enum.Enum):
     DATA = "CSV"
 
 
+class ReportCreationMethodType(str, enum.Enum):
+    CHARTS = "charts"
+    DASHBOARDS = "dashboards"
+    ALERTS_REPORTS = "alert_reports"

Review comment:
       ```suggestion
       ALERTS_REPORTS = "alerts_reports"
   ```

##########
File path: tests/integration_tests/reports/api_tests.py
##########
@@ -757,6 +773,82 @@ def test_create_report_schedule_relations_exist(self):
         data = json.loads(rv.data.decode("utf-8"))
         assert data == {"message": {"dashboard": "Dashboard does not exist"}}
 
+    @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+    # TODO (AAfghahi): I am going to enable this when the report schedule 
feature is fully finished
+    # def test_create_report_schedule_no_creation_method(self):
+    #     """
+    #     ReportSchedule Api: Test create report schedule
+    #     """
+    #     self.login(username="admin")
+
+    #     chart = db.session.query(Slice).first()
+    #     example_db = get_example_database()
+    #     report_schedule_data = {
+    #         "type": ReportScheduleType.ALERT,
+    #         "name": "new3",
+    #         "description": "description",
+    #         "crontab": "0 9 * * *",
+    #         "recipients": [
+    #             {
+    #                 "type": ReportRecipientType.EMAIL,
+    #                 "recipient_config_json": {"target": 
"[email protected]"},
+    #             },
+    #             {
+    #                 "type": ReportRecipientType.SLACK,
+    #                 "recipient_config_json": {"target": "channel"},
+    #             },
+    #         ],
+    #         "grace_period": 14400,
+    #         "working_timeout": 3600,
+    #         "chart": chart.id,
+    #         "database": example_db.id,
+    #     }
+    #     uri = "api/v1/report/"
+    #     rv = self.client.post(uri, json=report_schedule_data)
+    #     response = json.loads(rv.data.decode("utf-8"))
+    #     assert response == {
+    #         "message": {"creation_method": ["Missing data for required 
field."]}
+    #     }
+    #     assert rv.status_code == 400
+
+    @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+    def test_create_report_schedule_invalid_creation_method(self):
+        """
+        ReportSchedule Api: Test create report schedule

Review comment:
       ```suggestion
           ReportSchedule API: Test create report schedule
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to