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