Skip to content

Commit fd21c80

Browse files
committed
refactor tests
Signed-off-by: Aayush Kumar <[email protected]>
1 parent aca7d49 commit fd21c80

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

scanpipe/tests/test_models.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,27 +3055,20 @@ def test_scanpipe_discovered_package_model_unique_package_uid_in_project(self):
30553055
def test_scanpipe_codebase_resource_queryset_with_has_children(self):
30563056
project1 = make_project("Analysis")
30573057

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")
30733061

30743062
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)
30793072

30803073
@skipIf(connection.vendor == "sqlite", "No max_length constraints on SQLite.")
30813074
def test_scanpipe_codebase_resource_create_and_add_package_warnings(self):

0 commit comments

Comments
 (0)