@@ -378,3 +378,93 @@ def test_project_get_from_storage(project, mocker):
378
378
result ,
379
379
same_instance (project .storage_configuration .initialize_by_name .return_value ),
380
380
)
381
+
382
+
383
+ def test_get_pipelines_schema_multiple_pipelines (project , mocker ):
384
+ mock_schema = mocker .Mock (spec = Schema )
385
+ mock_coordinator = mocker .Mock ()
386
+ mock_coordinator .schema = mock_schema
387
+
388
+ mocker .patch (
389
+ "nodestream.project.project.SchemaExpansionCoordinator" ,
390
+ return_value = mock_coordinator ,
391
+ )
392
+
393
+ mock_pipeline1 = mocker .Mock ()
394
+ mock_pipeline1 .initialize_for_introspection = mocker .Mock ()
395
+ mock_pipeline1 .expand_schema = mocker .Mock ()
396
+
397
+ mock_pipeline2 = mocker .Mock ()
398
+ mock_pipeline2 .initialize_for_introspection = mocker .Mock ()
399
+ mock_pipeline2 .expand_schema = mocker .Mock ()
400
+
401
+ mocker .patch .object (
402
+ project , "get_pipeline_by_names" , return_value = [mock_pipeline1 , mock_pipeline2 ]
403
+ )
404
+
405
+ result = project .get_pipelines_schema (["test" , "test2" ])
406
+
407
+ mock_pipeline1 .initialize_for_introspection .assert_called_once ()
408
+ mock_pipeline1 .expand_schema .assert_called_once_with (coordinator = mock_coordinator )
409
+ mock_pipeline2 .initialize_for_introspection .assert_called_once ()
410
+ mock_pipeline2 .expand_schema .assert_called_once_with (coordinator = mock_coordinator )
411
+ assert_that (result , same_instance (mock_schema ))
412
+
413
+
414
+ def test_get_pipelines_schema_with_type_overrides (project , mocker ):
415
+ mock_base_schema = mocker .Mock (spec = Schema )
416
+ mock_overrides_schema = mocker .Mock (spec = Schema )
417
+ mock_coordinator = mocker .Mock ()
418
+ mock_coordinator .schema = mock_base_schema
419
+
420
+ mocker .patch (
421
+ "nodestream.project.project.SchemaExpansionCoordinator" ,
422
+ return_value = mock_coordinator ,
423
+ )
424
+ Schema .read_from_file = mocker .Mock (return_value = mock_overrides_schema )
425
+
426
+ mock_pipeline = mocker .Mock ()
427
+ mock_pipeline .initialize_for_introspection = mocker .Mock ()
428
+ mock_pipeline .expand_schema = mocker .Mock ()
429
+ mocker .patch .object (project , "get_pipeline_by_names" , return_value = [mock_pipeline ])
430
+
431
+ overrides_path = Path ("some/overrides.yaml" )
432
+ result = project .get_pipelines_schema (["test" ], overrides_path )
433
+
434
+ Schema .read_from_file .assert_called_once_with (overrides_path )
435
+ mock_base_schema .merge .assert_called_once_with (mock_overrides_schema )
436
+ assert_that (result , same_instance (mock_base_schema ))
437
+
438
+
439
+ def test_get_pipelines_schema_nonexistent_pipeline_raises_error (project , mocker ):
440
+ mocker .patch .object (project , "get_pipeline_by_names" , return_value = [])
441
+
442
+ with pytest .raises (ValueError ) as exc_info :
443
+ project .get_pipelines_schema (["nonexistent" ])
444
+
445
+ error_message = str (exc_info .value )
446
+ assert_that (
447
+ error_message ,
448
+ equal_to (
449
+ "None of the specified pipelines ['nonexistent'] were found. Available pipelines: ['test', 'test2']"
450
+ ),
451
+ )
452
+
453
+
454
+ def test_get_pipeline_by_names (project ):
455
+ pipelines = list (project .get_pipeline_by_names (["test" , "test2" ]))
456
+
457
+ assert_that (pipelines , has_length (2 ))
458
+ assert_that ([p .name for p in pipelines ], contains_inanyorder ("test" , "test2" ))
459
+
460
+
461
+ def test_get_pipeline_by_names_nonexistent_pipeline (project ):
462
+ pipelines = list (project .get_pipeline_by_names (["nonexistent" ]))
463
+ assert_that (pipelines , has_length (0 ))
464
+
465
+
466
+ def test_get_pipeline_by_names_mixed_existing_nonexisting (project ):
467
+ pipelines = list (project .get_pipeline_by_names (["test" , "nonexistent" , "test2" ]))
468
+
469
+ assert_that (pipelines , has_length (2 ))
470
+ assert_that ([p .name for p in pipelines ], contains_inanyorder ("test" , "test2" ))
0 commit comments