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