@@ -3055,27 +3055,20 @@ def test_scanpipe_discovered_package_model_unique_package_uid_in_project(self):
3055
3055
def test_scanpipe_codebase_resource_queryset_with_has_children (self ):
3056
3056
project1 = make_project ("Analysis" )
3057
3057
3058
- CodebaseResource .objects .create (
3059
- project = project1 ,
3060
- type = CodebaseResource .Type .DIRECTORY ,
3061
- path = "parent" ,
3062
- )
3063
- CodebaseResource .objects .create (
3064
- project = project1 ,
3065
- type = CodebaseResource .Type .FILE ,
3066
- path = "parent/child.txt" ,
3067
- )
3068
- CodebaseResource .objects .create (
3069
- project = project1 ,
3070
- type = CodebaseResource .Type .DIRECTORY ,
3071
- path = "empty" ,
3072
- )
3058
+ make_resource_directory (project1 , "parent" )
3059
+ make_resource_file (project1 , "parent/child.txt" )
3060
+ make_resource_directory (project1 , "empty" )
3073
3061
3074
3062
qs = CodebaseResource .objects .filter (project = project1 ).with_has_children ()
3075
- results = {r .path : r .has_children for r in qs }
3076
- self .assertTrue (results ["parent" ])
3077
- self .assertFalse (results ["parent/child.txt" ])
3078
- self .assertFalse (results ["empty" ])
3063
+
3064
+ resource1 = qs .get (path = "parent" )
3065
+ self .assertTrue (resource1 .has_children )
3066
+
3067
+ resource2 = qs .get (path = "parent/child.txt" )
3068
+ self .assertFalse (resource2 .has_children )
3069
+
3070
+ resource3 = qs .get (path = "empty" )
3071
+ self .assertFalse (resource3 .has_children )
3079
3072
3080
3073
@skipIf (connection .vendor == "sqlite" , "No max_length constraints on SQLite." )
3081
3074
def test_scanpipe_codebase_resource_create_and_add_package_warnings (self ):
0 commit comments