2121import logging
2222import time
2323import uuid
24- from datetime import datetime , timezone
24+ from datetime import datetime , timezone , UTC
2525from functools import wraps
2626from pathlib import Path
2727from typing import Any , Optional , Union
@@ -874,7 +874,7 @@ async def run_test_iteration(
874874 # Record start time
875875 start_time = time .time ()
876876 iteration_result ["start_time" ] = datetime .fromtimestamp (
877- start_time , tz = timezone . utc
877+ start_time , tz = UTC
878878 ).isoformat ()
879879
880880 # Get initial metrics if monitoring is enabled
@@ -891,7 +891,7 @@ async def run_test_iteration(
891891 # Record end time
892892 end_time = time .time ()
893893 iteration_result ["end_time" ] = datetime .fromtimestamp (
894- end_time , tz = timezone . utc
894+ end_time , tz = UTC
895895 ).isoformat ()
896896
897897 # Collect final metrics
@@ -1114,7 +1114,7 @@ async def create_mcp_plugin(
11141114 "mode" : mode ,
11151115 "spec_source" : spec_url_or_path ,
11161116 "target_url" : target_url ,
1117- "created_at" : datetime .now (timezone . utc ).isoformat (),
1117+ "created_at" : datetime .now (UTC ).isoformat (),
11181118 "plugin_config" : {},
11191119 "mcp_config" : {},
11201120 "mock_server_path" : None ,
@@ -1274,7 +1274,7 @@ async def create_mcp_plugin(
12741274 "mode" : mode ,
12751275 "spec_source" : spec_url_or_path ,
12761276 "error" : f"Plugin creation failed: { e !s} " ,
1277- "created_at" : datetime .now (timezone . utc ).isoformat (),
1277+ "created_at" : datetime .now (UTC ).isoformat (),
12781278 "plugin_config" : {},
12791279 "mcp_config" : {},
12801280 "mock_server_path" : None ,
@@ -1778,7 +1778,7 @@ def _generate_session_summary(session_data: dict[str, Any]) -> dict[str, Any]:
17781778def _calculate_next_execution (schedule_config : dict [str , Any ]) -> str :
17791779 """Calculate next execution time."""
17801780 # Simplified implementation
1781- return datetime .now (timezone . utc ).isoformat ()
1781+ return datetime .now (UTC ).isoformat ()
17821782
17831783
17841784def _validate_test_suite (test_suite : dict [str , Any ]) -> dict [str , bool ]:
@@ -2246,7 +2246,7 @@ async def generate_test_report(
22462246 "report_id" : str (uuid .uuid4 ()),
22472247 "report_format" : report_format ,
22482248 "output_format" : output_format ,
2249- "generated_at" : datetime .now (timezone . utc ).isoformat (),
2249+ "generated_at" : datetime .now (UTC ).isoformat (),
22502250 "report_content" : {},
22512251 "chart_data" : None ,
22522252 "export_data" : None ,
@@ -2299,7 +2299,7 @@ async def generate_test_report(
22992299 "report_format" : report_format ,
23002300 "output_format" : output_format ,
23012301 "error" : f"Report generation failed: { e !s} " ,
2302- "generated_at" : datetime .now (timezone . utc ).isoformat (),
2302+ "generated_at" : datetime .now (UTC ).isoformat (),
23032303 "report_content" : {},
23042304 "chart_data" : None ,
23052305 "export_data" : None ,
@@ -2543,7 +2543,7 @@ async def create_test_session(
25432543 "status" : "success" ,
25442544 "session_id" : session_id ,
25452545 "session_name" : session_name ,
2546- "created_at" : datetime .now (timezone . utc ).isoformat (),
2546+ "created_at" : datetime .now (UTC ).isoformat (),
25472547 "test_plan" : test_plan ,
25482548 "session_config" : session_config or {},
25492549 "session_state" : "created" ,
@@ -2567,7 +2567,7 @@ async def create_test_session(
25672567 "session_id" : None ,
25682568 "session_name" : session_name ,
25692569 "error" : f"Test session creation failed: { e !s} " ,
2570- "created_at" : datetime .now (timezone . utc ).isoformat (),
2570+ "created_at" : datetime .now (UTC ).isoformat (),
25712571 "test_plan" : {},
25722572 "session_config" : {},
25732573 "session_state" : "error" ,
@@ -2595,14 +2595,14 @@ async def end_test_session(
25952595 "status" : "error" ,
25962596 "session_id" : session_id ,
25972597 "error" : "Test session not found" ,
2598- "ended_at" : datetime .now (timezone . utc ).isoformat (),
2598+ "ended_at" : datetime .now (UTC ).isoformat (),
25992599 "final_report" : None ,
26002600 "session_summary" : {},
26012601 }
26022602
26032603 session_data = _active_test_sessions [session_id ]
26042604 session_data ["session_state" ] = "completed"
2605- session_data ["ended_at" ] = datetime .now (timezone . utc ).isoformat ()
2605+ session_data ["ended_at" ] = datetime .now (UTC ).isoformat ()
26062606
26072607 end_result = {
26082608 "status" : "success" ,
@@ -2636,7 +2636,7 @@ async def end_test_session(
26362636 "status" : "error" ,
26372637 "session_id" : session_id ,
26382638 "error" : f"Test session completion failed: { e !s} " ,
2639- "ended_at" : datetime .now (timezone . utc ).isoformat (),
2639+ "ended_at" : datetime .now (UTC ).isoformat (),
26402640 "final_report" : None ,
26412641 "session_summary" : {},
26422642 }
@@ -2667,7 +2667,7 @@ async def schedule_test_suite(
26672667 "test_suite" : test_suite ,
26682668 "schedule_config" : schedule_config ,
26692669 "notification_config" : notification_config or {},
2670- "created_at" : datetime .now (timezone . utc ).isoformat (),
2670+ "created_at" : datetime .now (UTC ).isoformat (),
26712671 "next_execution" : _calculate_next_execution (schedule_config ),
26722672 "schedule_state" : "active" ,
26732673 "validation_result" : _validate_test_suite (test_suite ),
@@ -2691,7 +2691,7 @@ async def schedule_test_suite(
26912691 "test_suite" : {},
26922692 "schedule_config" : {},
26932693 "notification_config" : {},
2694- "created_at" : datetime .now (timezone . utc ).isoformat (),
2694+ "created_at" : datetime .now (UTC ).isoformat (),
26952695 "next_execution" : None ,
26962696 "schedule_state" : "error" ,
26972697 "validation_result" : {"valid" : False , "errors" : []},
@@ -2722,7 +2722,7 @@ async def monitor_test_progress(
27222722 "progress" : {},
27232723 "performance_data" : {},
27242724 "alerts" : [],
2725- "monitoring_timestamp" : datetime .now (timezone . utc ).isoformat (),
2725+ "monitoring_timestamp" : datetime .now (UTC ).isoformat (),
27262726 }
27272727
27282728 session_data = _active_test_sessions [session_id ]
@@ -2736,7 +2736,7 @@ async def monitor_test_progress(
27362736 "progress_percentage" : _calculate_progress_percentage (progress ),
27372737 "performance_data" : {},
27382738 "alerts" : [],
2739- "monitoring_timestamp" : datetime .now (timezone . utc ).isoformat (),
2739+ "monitoring_timestamp" : datetime .now (UTC ).isoformat (),
27402740 }
27412741
27422742 # Include performance data if requested
@@ -2773,7 +2773,7 @@ async def monitor_test_progress(
27732773 "progress" : {},
27742774 "performance_data" : {},
27752775 "alerts" : [],
2776- "monitoring_timestamp" : datetime .now (timezone . utc ).isoformat (),
2776+ "monitoring_timestamp" : datetime .now (UTC ).isoformat (),
27772777 }
27782778
27792779
@@ -3099,7 +3099,7 @@ async def _register_mcp_plugin(plugin_config: PluginConfig) -> dict[str, Any]:
30993099 "status" : "success" ,
31003100 "registered" : True ,
31013101 "plugin_id" : plugin_config .mcp_server_name ,
3102- "registration_time" : datetime .now (timezone . utc ).isoformat (),
3102+ "registration_time" : datetime .now (UTC ).isoformat (),
31033103 "message" : f"Plugin { plugin_config .plugin_name } registered successfully" ,
31043104 }
31053105
@@ -3111,7 +3111,7 @@ async def _register_mcp_plugin(plugin_config: PluginConfig) -> dict[str, Any]:
31113111 "status" : "error" ,
31123112 "registered" : False ,
31133113 "error" : str (e ),
3114- "registration_time" : datetime .now (timezone . utc ).isoformat (),
3114+ "registration_time" : datetime .now (UTC ).isoformat (),
31153115 }
31163116
31173117
0 commit comments