Skip to content

Commit 2e12517

Browse files
committed
Fix parts of the failing tests #241
Signed-off-by: tdruez <[email protected]>
1 parent f03843c commit 2e12517

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

product_portfolio/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def submit(self, product, user):
678678

679679

680680
def validate_sbom_file(value):
681-
"""Validator for SBOM JSON file."""
681+
"""Validate SBOM JSON file content."""
682682
filename = value.name.lower()
683683
if not filename.endswith(".json"):
684684
return
@@ -695,7 +695,7 @@ def validate_sbom_file(value):
695695
tool_name = headers[0].get("tool_name", "")
696696
if "scan" in tool_name.lower():
697697
raise ValidationError(
698-
'Your file appears to be a ScanCode scan results. '
698+
"Your file appears to be a ScanCode scan results. "
699699
'You want to use the "Import ScanCode scan results" action instead.'
700700
)
701701

product_portfolio/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ def test_api_product_endpoint_load_sboms_action(self):
371371
self.assertEqual(expected, response.data)
372372

373373
data = {
374-
"input_file": ContentFile("Content", name="sbom.json"),
374+
"input_file": ContentFile("{}", name="sbom.json"),
375375
"update_existing_packages": False,
376376
"scan_all_packages": False,
377377
}

product_portfolio/tests/test_views.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ def test_product_portfolio_detail_view_tab_imports_view(self):
223223
htmx_refresh = 'hx-trigger="load delay:10s" hx-swap="outerHTML"'
224224
self.assertContains(response, htmx_refresh)
225225
self.assertContains(response, "Imports are currently in progress.")
226-
self.assertContains(response, "Import SBOMs")
226+
self.assertContains(response, "Import SBOM")
227227

228228
project.status = ScanCodeProject.Status.SUCCESS
229229
project.save()
230230
response = self.client.get(url)
231231
self.assertFalse(response.context["has_projects_in_progress"])
232-
self.assertContains(response, "Import SBOMs")
232+
self.assertContains(response, "Import SBOM")
233233
self.assertNotContains(response, "hx-trigger")
234234
self.assertNotContains(response, "Imports are currently in progress.")
235235

@@ -3090,15 +3090,14 @@ def test_product_portfolio_load_sbom_view(self, mock_submit):
30903090
expected = "Import SBOM"
30913091
self.assertContains(response, expected)
30923092

3093-
data = {"input_file": ContentFile("Data")}
3093+
data = {"input_file": ContentFile("{}", name="file.json")}
30943094
response = self.client.post(url, data=data, follow=True)
30953095
expected = "SBOM file submitted to ScanCode.io for inspection."
30963096
self.assertContains(response, expected)
30973097
self.assertEqual(1, ScanCodeProject.objects.count())
30983098

30993099
with override_settings(CLAMD_ENABLED=True):
31003100
with mock.patch("dje.fields.SmartFileField.scan_file_for_virus") as scan:
3101-
data = {"input_file": ContentFile("Data")}
31023101
self.client.post(url, data=data, follow=True)
31033102
scan.assert_called_once()
31043103

0 commit comments

Comments
 (0)