@@ -1240,7 +1240,85 @@ def test_get_created_workflow_logs(
1240
1240
),
1241
1241
}
1242
1242
assert response_data == expected_data
1243
- mock_method .call_count == 2
1243
+ assert mock_method .call_count == 2
1244
+
1245
+
1246
+ def test_get_created_workflow_logs_by_steps (
1247
+ app ,
1248
+ user0 ,
1249
+ cwl_workflow_with_name ,
1250
+ tmp_shared_volume_path ,
1251
+ session ,
1252
+ ):
1253
+ """Test get workflow logs, filtering by steps."""
1254
+ with app .test_client () as client :
1255
+ # Create the workflow
1256
+ res = client .post (
1257
+ url_for ("workflows.create_workflow" ),
1258
+ query_string = {
1259
+ "user" : user0 .id_ ,
1260
+ "workspace_root_path" : tmp_shared_volume_path ,
1261
+ },
1262
+ content_type = "application/json" ,
1263
+ data = json .dumps (cwl_workflow_with_name ),
1264
+ )
1265
+
1266
+ # Get the generated workflow UUID
1267
+ response_data = json .loads (res .get_data (as_text = True ))
1268
+ workflow_uuid = response_data .get ("workflow_id" )
1269
+ workflow_name = response_data .get ("workflow_name" )
1270
+
1271
+ # Create a job for the workflow
1272
+ workflow_job = Job (
1273
+ id_ = uuid .UUID ("9a22c3a4-6d72-4812-93e7-7e0efdeb985d" ),
1274
+ workflow_uuid = workflow_uuid ,
1275
+ )
1276
+ workflow_job .status = "running"
1277
+ workflow_job .logs = "test job logs"
1278
+ workflow_job .job_name = "gendata"
1279
+ session .add (workflow_job )
1280
+ session .commit ()
1281
+
1282
+ # Call the API to fetch the workflow logs, filtering by steps
1283
+ res = client .get (
1284
+ url_for ("statuses.get_workflow_logs" , workflow_id_or_name = workflow_uuid ),
1285
+ query_string = {"user" : user0 .id_ },
1286
+ content_type = "application/json" ,
1287
+ data = json .dumps (["gendata" , "fitdata" ]),
1288
+ )
1289
+
1290
+ # Expect a successful response
1291
+ assert res .status_code == 200
1292
+
1293
+ # Check the response data is as expected
1294
+ response_data = json .loads (res .get_data (as_text = True ))
1295
+ expected_data = {
1296
+ "workflow_id" : workflow_uuid ,
1297
+ "workflow_name" : workflow_name ,
1298
+ "user" : str (user0 .id_ ),
1299
+ "live_logs_enabled" : False ,
1300
+ "logs" : json .dumps (
1301
+ {
1302
+ "workflow_logs" : None ,
1303
+ "job_logs" : {
1304
+ str (workflow_job .id_ ): {
1305
+ "workflow_uuid" : str (workflow_job .workflow_uuid ),
1306
+ "job_name" : workflow_job .job_name ,
1307
+ "compute_backend" : "" ,
1308
+ "backend_job_id" : "" ,
1309
+ "docker_img" : "" ,
1310
+ "cmd" : "" ,
1311
+ "status" : workflow_job .status .name ,
1312
+ "logs" : "test job logs" ,
1313
+ "started_at" : None ,
1314
+ "finished_at" : None ,
1315
+ }
1316
+ },
1317
+ "engine_specific" : None ,
1318
+ }
1319
+ ),
1320
+ }
1321
+ assert response_data == expected_data
1244
1322
1245
1323
1246
1324
def test_get_created_workflow_opensearch_disabled (
0 commit comments