SIENTIAPDE-1184
SIENTIAPDE-1184 refactor: improve schedule reporting in Formatters class - Introduced a unified reporting structure for created, updated, and deleted schedules. - Enhanced success and error report messages for clarity, including specific schedule types in notifications. - Updated attachment handling in success and error reports to improve context and readability.
This commit is contained in:
@@ -466,21 +466,6 @@ async def test_create_slot_config(formatters):
|
||||
|
||||
def test_send_success_report(formatters):
|
||||
formatters.send_success_report(
|
||||
metadata=metadata,
|
||||
message="test_message",
|
||||
notification_id="test_notification_id"
|
||||
)
|
||||
formatters.send_notification.assert_called_once_with(
|
||||
metadata=metadata,
|
||||
notification_id="test_notification_id",
|
||||
message="test_message",
|
||||
block="report_orchestration",
|
||||
level=NotificationLevel.INFO
|
||||
)
|
||||
|
||||
|
||||
def test_send_error_report(formatters):
|
||||
formatters.send_error_report(
|
||||
metadata=metadata,
|
||||
message="test_message",
|
||||
notification_id="test_notification_id",
|
||||
@@ -491,12 +476,29 @@ def test_send_error_report(formatters):
|
||||
notification_id="test_notification_id",
|
||||
message="test_message",
|
||||
block="report_orchestration",
|
||||
level=NotificationLevel.ERROR,
|
||||
level=NotificationLevel.INFO,
|
||||
attachment_content=json.dumps(
|
||||
{"test": "test"}, indent=4, sort_keys=True)
|
||||
)
|
||||
|
||||
|
||||
def test_send_error_report(formatters):
|
||||
formatters.send_error_report(
|
||||
metadata=metadata,
|
||||
message="test_message",
|
||||
notification_id="test_notification_id",
|
||||
attachment="test_attachment"
|
||||
)
|
||||
formatters.send_notification.assert_called_once_with(
|
||||
metadata=metadata,
|
||||
notification_id="test_notification_id",
|
||||
message="test_message",
|
||||
block="report_orchestration",
|
||||
level=NotificationLevel.ERROR,
|
||||
attachment_content="test_attachment"
|
||||
)
|
||||
|
||||
|
||||
def test_parse_report(formatters):
|
||||
input_data = {
|
||||
"test_key": {
|
||||
@@ -631,19 +633,19 @@ async def test_report_schedule_orchestration(formatters):
|
||||
formatters.send_success_report.assert_has_calls([
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Created schedules: \n test_namespace/test_schedule_name_to_create",
|
||||
message="Successfully created schedules: \n test_namespace/test_schedule_name_to_create",
|
||||
notification_id="REPORT_ORCHESTRATION_CREATED_SCHEDULES",
|
||||
attachment=input_data['created_schedules']
|
||||
),
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Updated schedules: \n test_namespace/test_schedule_name_to_update",
|
||||
message="Successfully updated schedules: \n test_namespace/test_schedule_name_to_update",
|
||||
notification_id="REPORT_ORCHESTRATION_UPDATED_SCHEDULES",
|
||||
attachment=input_data['updated_schedules']
|
||||
),
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Deleted schedules: \n test_namespace/test_schedule_name_to_delete",
|
||||
message="Successfully deleted schedules: \n test_namespace/test_schedule_name_to_delete",
|
||||
notification_id="REPORT_ORCHESTRATION_DELETED_SCHEDULES",
|
||||
attachment=input_data['deleted_schedules']
|
||||
)
|
||||
@@ -651,21 +653,21 @@ async def test_report_schedule_orchestration(formatters):
|
||||
formatters.send_error_report.assert_has_calls([
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Failed to create schedules: \n test_namespace/test_schedule_name_to_create_error, test_namespace/test_schedule_name_to_create_error2",
|
||||
message="Fails on created schedules: \n test_namespace/test_schedule_name_to_create_error, test_namespace/test_schedule_name_to_create_error2",
|
||||
notification_id="REPORT_ORCHESTRATION_CREATED_SCHEDULES_ERROR",
|
||||
attachment="test_error1\ntest_attachment1\n ========== \ntest_error2"
|
||||
attachment="test_namespace/test_schedule_name_to_create_error:\ntest_error1\ntest_attachment1\n ========== \ntest_namespace/test_schedule_name_to_create_error2:\ntest_error2"
|
||||
),
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Failed to update schedules: \n test_namespace/test_schedule_name_to_update_error, test_namespace/test_schedule_name_to_update_error2, test_namespace/test_schedule_name_to_update_error3",
|
||||
message="Fails on updated schedules: \n test_namespace/test_schedule_name_to_update_error, test_namespace/test_schedule_name_to_update_error2, test_namespace/test_schedule_name_to_update_error3",
|
||||
notification_id="REPORT_ORCHESTRATION_UPDATED_SCHEDULES_ERROR",
|
||||
attachment="test_error2\ntest_attachment2\n ========== \ntest_error3\ntest_attachment3\n ========== \ntest_error4"
|
||||
attachment="test_namespace/test_schedule_name_to_update_error:\ntest_error2\ntest_attachment2\n ========== \ntest_namespace/test_schedule_name_to_update_error2:\ntest_error3\ntest_attachment3\n ========== \ntest_namespace/test_schedule_name_to_update_error3:\ntest_error4"
|
||||
),
|
||||
call(
|
||||
metadata=metadata['metadata'],
|
||||
message="Failed to delete schedules: \n test_namespace/test_schedule_name_to_delete_error, test_namespace/test_schedule_name_to_delete_error2",
|
||||
message="Fails on deleted schedules: \n test_namespace/test_schedule_name_to_delete_error, test_namespace/test_schedule_name_to_delete_error2",
|
||||
notification_id="REPORT_ORCHESTRATION_DELETED_SCHEDULES_ERROR",
|
||||
attachment="test_error4\ntest_attachment4\n ========== \ntest_error5"
|
||||
attachment="test_namespace/test_schedule_name_to_delete_error:\ntest_error4\ntest_attachment4\n ========== \ntest_namespace/test_schedule_name_to_delete_error2:\ntest_error5"
|
||||
)
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user