@@ -860,6 +860,64 @@ def test_scanpipe_scan_codebase_pipeline_integration(self):
860
860
expected_file = self .data / "scancode" / "is-npm-1.0.0_scan_codebase.json"
861
861
self .assertPipelineResultEqual (expected_file , result_file )
862
862
863
+ def test_scanpipe_scan_codebase_creates_top_level_paths (self ):
864
+ pipeline_name = "scan_codebase"
865
+ project1 = make_project ()
866
+
867
+ filename = "is-npm-1.0.0.tgz"
868
+ input_location = self .data / "scancode" / filename
869
+ project1 .copy_input_from (input_location )
870
+
871
+ run = project1 .add_pipeline (pipeline_name )
872
+ pipeline = run .make_pipeline_instance ()
873
+
874
+ exitcode , out = pipeline .execute ()
875
+ self .assertEqual (0 , exitcode , msg = out )
876
+
877
+ expected_top_level_paths = ["is-npm-1.0.0.tgz" , "is-npm-1.0.0.tgz-extract" ]
878
+
879
+ top_level_resources = project1 .codebaseresources .filter (
880
+ parent_directory_path = None
881
+ )
882
+ top_level_paths = [res .path for res in top_level_resources ]
883
+
884
+ self .assertListEqual (top_level_paths , expected_top_level_paths )
885
+
886
+ def test_scanpipe_scan_codebase_creates_parent_directory_path_field (self ):
887
+ pipeline_name = "scan_codebase"
888
+ project1 = make_project ()
889
+
890
+ filename = "is-npm-1.0.0.tgz"
891
+ input_location = self .data / "scancode" / filename
892
+ project1 .copy_input_from (input_location )
893
+
894
+ run = project1 .add_pipeline (pipeline_name )
895
+ pipeline = run .make_pipeline_instance ()
896
+
897
+ exitcode , out = pipeline .execute ()
898
+ self .assertEqual (0 , exitcode , msg = out )
899
+
900
+ expected_top_level_paths = ["is-npm-1.0.0.tgz" , "is-npm-1.0.0.tgz-extract" ]
901
+ expected_nested_paths = [
902
+ "is-npm-1.0.0.tgz-extract/package/index.js" ,
903
+ "is-npm-1.0.0.tgz-extract/package/package.json" ,
904
+ "is-npm-1.0.0.tgz-extract/package/readme.md" ,
905
+ ]
906
+
907
+ top_level_resources = project1 .codebaseresources .filter (
908
+ parent_directory_path = None
909
+ )
910
+ top_level_paths = [res .path for res in top_level_resources ]
911
+
912
+ self .assertListEqual (top_level_paths , expected_top_level_paths )
913
+
914
+ nested_resources = project1 .codebaseresources .filter (
915
+ parent_directory_path = "is-npm-1.0.0.tgz-extract/package"
916
+ )
917
+ nested_paths = [res .path for res in nested_resources ]
918
+
919
+ self .assertListEqual (nested_paths , expected_nested_paths )
920
+
863
921
def test_scanpipe_inspect_packages_creates_packages_npm (self ):
864
922
pipeline_name = "inspect_packages"
865
923
project1 = make_project ()
0 commit comments