11import os
2- import sys
32import json
43
54print ("Checking ticket classification agent output..." )
65
76# Check NuGet package
87uipath_dir = ".uipath"
9- if not os .path .exists (uipath_dir ):
10- print ("NuGet package directory (.uipath) not found" )
11- sys .exit (1 )
8+ assert os .path .exists (uipath_dir ), "NuGet package directory (.uipath) not found"
129
1310nupkg_files = [f for f in os .listdir (uipath_dir ) if f .endswith ('.nupkg' )]
14- if not nupkg_files :
15- print ("NuGet package file (.nupkg) not found in .uipath directory" )
16- sys .exit (1 )
11+ assert nupkg_files , "NuGet package file (.nupkg) not found in .uipath directory"
1712
1813print (f"NuGet package found: { nupkg_files [0 ]} " )
1914
2015# Check agent output file
2116output_file = "__uipath/output.json"
22- if not os .path .isfile (output_file ):
23- print ("Agent output file not found" )
24- sys .exit (1 )
17+ assert os .path .isfile (output_file ), "Agent output file not found"
2518
2619print ("Agent output file found" )
2720
2821# Check status and required fields
29- try :
30- with open (output_file , 'r' , encoding = 'utf-8' ) as f :
31- output_data = json .load (f )
32-
33- # Check status
34- status = output_data .get ("status" )
35- if status != "successful" :
36- print (f"Agent execution failed with status: { status } " )
37- sys .exit (1 )
38-
39- print ("Agent execution status: successful" )
40-
41- # Check required fields for ticket classification agent
42- if "output" not in output_data :
43- print ("Missing 'output' field in agent response" )
44- sys .exit (1 )
45-
46- output_content = output_data ["output" ]
47- if "label" not in output_content :
48- print ("Missing 'label' field in output" )
49- sys .exit (1 )
50-
51- label = output_content ["label" ]
52- if not label or label .strip () == "" :
53- print ("Label field is empty" )
54- sys .exit (1 )
22+ with open (output_file , 'r' , encoding = 'utf-8' ) as f :
23+ output_data = json .load (f )
24+
25+ # Check status
26+ status = output_data .get ("status" )
27+ assert status == "successful" , f"Agent execution failed with status: { status } "
28+
29+ print ("Agent execution status: successful" )
30+
31+ # Check required fields for ticket classification agent
32+ assert "output" in output_data , "Missing 'output' field in agent response"
33+
34+ output_content = output_data ["output" ]
35+ assert "label" in output_content , "Missing 'label' field in output"
36+
37+ label = output_content ["label" ]
38+ assert label and label .strip () != "" , "Label field is empty"
39+
40+ assert "confidence" in output_content , "Missing 'confidence' field in output"
41+
42+ confidence = output_content ["confidence" ]
43+ assert confidence is not None and confidence != "" , "Confidence field is empty"
44+
45+ with open ("local_run_output.log" , 'r' , encoding = 'utf-8' ) as f :
46+ local_run_output = f .read ()
47+
48+ # Check if response contains 'Successful execution.'
49+ assert "Successful execution." in local_run_output , f"Response does not contain 'Successful execution.'. Actual response: { local_run_output } "
5550
56- if "confidence" not in output_content :
57- print ("Missing 'confidence' field in output" )
58- sys .exit (1 )
59-
60- confidence = output_content ["confidence" ]
61- if confidence is None or confidence == "" :
62- print ("Confidence field is empty" )
63- sys .exit (1 )
64-
65-
66- print ("Required fields validation passed" )
67- print ("Ticket classification agent working correctly." )
68-
69- except Exception as e :
70- print (f"Error checking output: { e } " )
71- sys .exit (1 )
51+ print ("Required fields validation passed" )
0 commit comments