@@ -397,90 +397,10 @@ def test_create_version_reports(requests_mock, mock_hub_instance):
397
397
def test_create_version_notices_report (requests_mock , mock_hub_instance ):
398
398
pass
399
399
400
- @pytest .fixture ()
401
- def unreviewed_snippet_json (shared_datadir ):
402
- with (shared_datadir / "unreviewed_snippet.json" ).open () as f :
403
- yield json .load (f )[0 ]
404
-
405
- def test_get_ignore_snippet_json (unreviewed_snippet_json , mock_hub_instance ):
406
- assert 'fileSnippetBomComponents' in unreviewed_snippet_json
407
- assert unreviewed_snippet_json ['fileSnippetBomComponents' ][0 ]['ignored' ] == False
408
-
409
- result = mock_hub_instance .get_ignore_snippet_json (unreviewed_snippet_json )
410
-
411
- assert isinstance (result , list )
412
- assert len (result ) == 1
413
- assert 'fileSnippetBomComponents' in result [0 ]
414
- assert 'ignored' in result [0 ]['fileSnippetBomComponents' ][0 ]
415
- assert 'reviewStatus' in result [0 ]['fileSnippetBomComponents' ][0 ]
416
- assert result [0 ]['fileSnippetBomComponents' ][0 ]['ignored' ] == True
417
- assert result [0 ]['fileSnippetBomComponents' ][0 ]['reviewStatus' ] == 'NOT_REVIEWED'
418
-
419
- def test_get_confirm_snippet_json (unreviewed_snippet_json , mock_hub_instance ):
420
- assert 'fileSnippetBomComponents' in unreviewed_snippet_json
421
- assert unreviewed_snippet_json ['fileSnippetBomComponents' ][0 ]['ignored' ] == False
422
-
423
- result = mock_hub_instance .get_confirm_snippet_json (unreviewed_snippet_json )
424
-
425
- assert isinstance (result , list )
426
- assert len (result ) == 1
427
- assert 'fileSnippetBomComponents' in result [0 ]
428
- assert 'ignored' in result [0 ]['fileSnippetBomComponents' ][0 ]
429
- assert 'reviewStatus' in result [0 ]['fileSnippetBomComponents' ][0 ]
430
- assert result [0 ]['fileSnippetBomComponents' ][0 ]['ignored' ] == False
431
- assert result [0 ]['fileSnippetBomComponents' ][0 ]['reviewStatus' ] == 'REVIEWED'
432
-
433
-
434
- @pytest .fixture ()
435
- def sample_snippet_match_json (shared_datadir ):
436
- yield json .load ((shared_datadir / "sample-snippet-match.json" ).open ())
437
-
438
-
439
- def test_generate_new_match_selection (sample_snippet_match_json , mock_hub_instance ):
440
- assert 'fileSnippetBomComponents' in sample_snippet_match_json
441
- assert len (sample_snippet_match_json ['fileSnippetBomComponents' ]) == 1
442
-
443
- # Copy the snippet component match data and delete the keys that are normally missing
444
- # from a (vanilla) snippet component alternate match
445
- new_component = copy .deepcopy (sample_snippet_match_json ['fileSnippetBomComponents' ][0 ])
446
- del new_component ['ignored' ]
447
- del new_component ['reviewStatus' ]
448
- del new_component ['versionBomComponentId' ]
449
- new_component ['release' ]['version' ] = 'different-version'
450
-
451
- # now verify that they are restored when we prepare to select/update using the alternate match
452
- update_body = mock_hub_instance ._generate_new_match_selection (sample_snippet_match_json , new_component )
453
-
454
- assert len (update_body ) == 1
455
- assert 'fileSnippetBomComponents' in update_body [0 ]
456
- assert len (update_body [0 ]['fileSnippetBomComponents' ]) == 1
457
- updated_component_info = update_body [0 ]['fileSnippetBomComponents' ][0 ]
458
- original_component_info = sample_snippet_match_json ['fileSnippetBomComponents' ][0 ]
459
- for k in ['ignored' , 'reviewStatus' , 'versionBomComponentId' ]:
460
- assert k in updated_component_info
461
- assert updated_component_info [k ] == original_component_info [k ]
462
-
463
400
@pytest .fixture ()
464
401
def sample_bom_component_json (shared_datadir ):
465
402
yield json .load ((shared_datadir / "sample-bom-component.json" ).open ())
466
403
467
- def test_get_edit_snippet_json (sample_snippet_match_json , sample_bom_component_json , mock_hub_instance ):
468
- assert 'component' in sample_bom_component_json
469
- assert 'componentVersion' in sample_bom_component_json
470
- assert 'fileSnippetBomComponents' in sample_snippet_match_json
471
- assert len (sample_snippet_match_json ['fileSnippetBomComponents' ]) == 1
472
-
473
- new_component_id = sample_bom_component_json ['component' ].split ("/" )[- 1 ]
474
- new_component_version_id = sample_bom_component_json ['componentVersion' ].split ("/" )[- 1 ]
475
-
476
- new_snippet_bom_entry_l = mock_hub_instance .get_edit_snippet_json (sample_snippet_match_json , sample_bom_component_json )
477
-
478
- assert len (new_snippet_bom_entry_l ) == 1
479
- new_snippet_bom_entry = new_snippet_bom_entry_l [0 ]
480
-
481
- assert new_component_id == new_snippet_bom_entry ['fileSnippetBomComponents' ][0 ]['project' ]['id' ]
482
- assert new_component_version_id == new_snippet_bom_entry ['fileSnippetBomComponents' ][0 ]['release' ]['id' ]
483
-
484
404
@pytest .fixture ()
485
405
def no_roles_user (shared_datadir ):
486
406
yield json .load ((shared_datadir / 'no-roles-user.json' ).open ())
0 commit comments