Skip to content

Commit 18b9135

Browse files
committed
Add tests for models
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 17bcfce commit 18b9135

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

scanpipe/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,8 +1929,8 @@ def has_directory_content_fingerprint(self):
19291929

19301930
def elfs(self):
19311931
"""
1932-
Resources that are ``files`` and their filetype startswith `elf` and contains any of thes
1933-
`executable`, `relocatable`, `shared object`.
1932+
Resources that are ``files`` and their filetype startswith `elf` and
1933+
contains any of these `executable`, `relocatable`, `shared object`.
19341934
"""
19351935
return (
19361936
self.files()

scanpipe/tests/test_models.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,6 +2085,45 @@ def test_scanpipe_codebase_resource_queryset_has_directory_content_fingerprint(
20852085
results = self.project1.codebaseresources.has_directory_content_fingerprint()
20862086
self.assertQuerySetEqual(expected, results, ordered=False)
20872087

2088+
def test_scanpipe_codebase_resource_elfs(self):
2089+
project = Project.objects.create(name="Test")
2090+
CodebaseResource.objects.create(
2091+
file_type="""ELF 32-bit LSB executable, ARM, version 1 (ARM), statically
2092+
linked, with debug_info, not stripped""",
2093+
project=project,
2094+
path="a",
2095+
type=CodebaseResource.Type.FILE,
2096+
)
2097+
CodebaseResource.objects.create(
2098+
file_type="""32-bit LSB executable, ARM, version 1 (ARM), statically
2099+
linked, with debug_info, not stripped""",
2100+
project=project,
2101+
path="b",
2102+
type=CodebaseResource.Type.FILE,
2103+
)
2104+
CodebaseResource.objects.create(
2105+
file_type="""ELF 32-bit LSB resourcable, ARM, version 1 (ARM), statically
2106+
linked, with debug_info, not stripped""",
2107+
project=project,
2108+
path="c",
2109+
type=CodebaseResource.Type.FILE,
2110+
)
2111+
CodebaseResource.objects.create(
2112+
file_type="""32-bit LSB relocatable, ARM, version 1 (ARM), statically
2113+
linked, with debug_info, not stripped""",
2114+
project=project,
2115+
path="d",
2116+
type=CodebaseResource.Type.FILE,
2117+
)
2118+
CodebaseResource.objects.create(
2119+
file_type="""ELF 32-bit LSB relocatable, ARM, version 1 (ARM), statically
2120+
linked, with debug_info, not stripped""",
2121+
project=project,
2122+
path="e",
2123+
type=CodebaseResource.Type.FILE,
2124+
)
2125+
self.assertEqual(2, project.codebaseresources.elfs().count())
2126+
20882127

20892128
class ScanPipeModelsTransactionTest(TransactionTestCase):
20902129
"""

0 commit comments

Comments
 (0)