@@ -260,7 +260,56 @@ def scan(self, base: str, pattern: str):
260260 for t in glob .iglob (os .path .join (base , pattern ), recursive = True ):
261261 self .report (t )
262262
263+ def upload_raw_file (self , file_path : str ) -> bool :
264+
265+ try :
266+ # Debug: verify we're using the right code
267+ self .logger .debug ("Using updated upload_raw_file method" )
268+
269+ # Build the full URL with /intake prefix
270+ path = f"/intake/organizations/{ self .org } /workspaces/{ self .workspace } /{ self .session .subpath ('test_result_file' )} "
271+ url = f"{ self .client .base_url ()} { path } "
272+
273+ with open (file_path , 'rb' ) as f :
274+ files = {'file' : (os .path .basename (file_path ), f )}
275+ headers = self .client .http_client ._headers (compress = False )
276+ # Remove Content-Type header to let requests set it for multipart
277+ headers .pop ('Content-Type' , None )
278+
279+ response = self .client .http_client .session .request (
280+ 'POST' ,
281+ url ,
282+ files = files ,
283+ headers = headers ,
284+ timeout = (5 , 60 ),
285+ verify = (not self .client .http_client .skip_cert_verification )
286+ )
287+
288+ if response .status_code == 200 :
289+ self .logger .debug (f"Uploaded raw test result file: { file_path } " )
290+ return True
291+ else :
292+ self .logger .warning (
293+ f"Failed to upload raw test result file { file_path } : "
294+ f"HTTP { response .status_code } - { response .reason } "
295+ )
296+ return False
297+
298+ except Exception as e :
299+ self .logger .warning (f"Error uploading raw test result file { file_path } : { str (e )} " )
300+ return False
301+
302+ def upload_raw_files (self ) -> None :
303+
304+ if self .reports and not self .dry_run :
305+ self .logger .debug (f"Uploading { len (self .reports )} raw test result file(s)" )
306+ for report_file in self .reports :
307+ self .upload_raw_file (report_file )
308+
263309 def run (self ):
310+ # Upload raw test result files before parsing
311+ self .upload_raw_files ()
312+
264313 count = 0 # count number of test cases sent
265314 is_observation = False
266315
0 commit comments