Skip to content

Commit 3221e8b

Browse files
committed
refactor tests
Signed-off-by: Aayush Kumar <[email protected]>
1 parent 086fb51 commit 3221e8b

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
@@ -3014,27 +3014,20 @@ def test_scanpipe_discovered_package_model_unique_package_uid_in_project(self):
30143014
def test_scanpipe_codebase_resource_queryset_with_has_children(self):
30153015
project1 = make_project("Analysis")
30163016

3017-
CodebaseResource.objects.create(
3018-
project=project1,
3019-
type=CodebaseResource.Type.DIRECTORY,
3020-
path="parent",
3021-
)
3022-
CodebaseResource.objects.create(
3023-
project=project1,
3024-
type=CodebaseResource.Type.FILE,
3025-
path="parent/child.txt",
3026-
)
3027-
CodebaseResource.objects.create(
3028-
project=project1,
3029-
type=CodebaseResource.Type.DIRECTORY,
3030-
path="empty",
3031-
)
3017+
make_resource_directory(project1, "parent")
3018+
make_resource_file(project1, "parent/child.txt")
3019+
make_resource_directory(project1, "empty")
30323020

30333021
qs = CodebaseResource.objects.filter(project=project1).with_has_children()
3034-
results = {r.path: r.has_children for r in qs}
3035-
self.assertTrue(results["parent"])
3036-
self.assertFalse(results["parent/child.txt"])
3037-
self.assertFalse(results["empty"])
3022+
3023+
resource1 = qs.get(path="parent")
3024+
self.assertTrue(resource1.has_children)
3025+
3026+
resource2 = qs.get(path="parent/child.txt")
3027+
self.assertFalse(resource2.has_children)
3028+
3029+
resource3 = qs.get(path="empty")
3030+
self.assertFalse(resource3.has_children)
30383031

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

0 commit comments

Comments
 (0)