-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a TODOs sheet containing on REQUIRES_REVIEW resources in XLSX #1524
Signed-off-by: tdruez <[email protected]>
- Loading branch information
Showing
2 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
from django.core.management import call_command | ||
from django.test import TestCase | ||
|
||
import openpyxl | ||
import xlsxwriter | ||
from licensedcode.cache import get_licensing | ||
from lxml import etree | ||
|
@@ -42,10 +43,12 @@ | |
from scanpipe.models import CodebaseResource | ||
from scanpipe.models import Project | ||
from scanpipe.models import ProjectMessage | ||
from scanpipe.pipes import flag | ||
from scanpipe.pipes import output | ||
from scanpipe.tests import FIXTURES_REGEN | ||
from scanpipe.tests import make_dependency | ||
from scanpipe.tests import make_package | ||
from scanpipe.tests import make_resource_file | ||
from scanpipe.tests import mocked_now | ||
from scanpipe.tests import package_data1 | ||
|
||
|
@@ -210,16 +213,30 @@ def test_scanpipe_pipes_outputs_to_xlsx(self): | |
model="Model", | ||
details={}, | ||
) | ||
make_resource_file( | ||
project=project, path="path/file1.ext", status=flag.REQUIRES_REVIEW | ||
) | ||
|
||
output_file = output.to_xlsx(project=project) | ||
self.assertIn(output_file.name, project.output_root) | ||
|
||
# Make sure the output can be generated even if the work_directory was wiped | ||
shutil.rmtree(project.work_directory) | ||
with self.assertNumQueries(8): | ||
with self.assertNumQueries(9): | ||
output_file = output.to_xlsx(project=project) | ||
self.assertIn(output_file.name, project.output_root) | ||
|
||
workbook = openpyxl.load_workbook(output_file, read_only=True, data_only=True) | ||
expected_sheet_names = [ | ||
"PACKAGES", | ||
"DEPENDENCIES", | ||
"RESOURCES", | ||
"RELATIONS", | ||
"MESSAGES", | ||
"TODOS", | ||
] | ||
self.assertEqual(expected_sheet_names, workbook.get_sheet_names()) | ||
|
||
def test_scanpipe_pipes_outputs_vulnerability_as_cyclonedx(self): | ||
component_bom_ref = "pkg:pypi/[email protected]" | ||
data = self.data / "cyclonedx/django-4.0.10-vulnerability.json" | ||
|
@@ -480,6 +497,34 @@ def test_scanpipe_pipes_outputs_to_attribution(self): | |
output_file = output.to_attribution(project=project) | ||
self.assertEqual("EMPTY_TEMPLATE", output_file.read_text()) | ||
|
||
def test_scanpipe_pipes_outputs_get_todos_data(self): | ||
project = Project.objects.create(name="Analysis") | ||
todos_data = output.get_todos_data(project) | ||
self.assertEqual([], list(todos_data)) | ||
|
||
make_resource_file( | ||
project=project, path="path/file1.ext", status=flag.REQUIRES_REVIEW | ||
) | ||
make_resource_file(project=project, path="path/file2.ext") | ||
|
||
todos_data = output.get_todos_data(project) | ||
expected = [ | ||
{ | ||
"path": "path/file1.ext", | ||
"status": "requires-review", | ||
"size": None, | ||
"name": "file1.ext", | ||
"extension": ".ext", | ||
"programming_language": "", | ||
"mime_type": "", | ||
"tag": "path", | ||
"detected_license_expression": "", | ||
"compliance_alert": "", | ||
"project__name": "Analysis", | ||
} | ||
] | ||
self.assertEqual(expected, list(todos_data)) | ||
|
||
|
||
class ScanPipeXLSXOutputPipesTest(TestCase): | ||
def test__add_xlsx_worksheet_does_truncates_long_strings_over_max_len(self): | ||
|