Skip to content

Commit b20ce50

Browse files
Fix SCIO tests
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent a025a5e commit b20ce50

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

scanpipe/pipes/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def update_or_create_dependency(
249249
def update_or_create_license_detection(
250250
project,
251251
detection_data,
252-
resource_path,
252+
resource_path=None,
253253
from_package=False,
254254
):
255255
"""
@@ -277,6 +277,14 @@ def update_or_create_license_detection(
277277
detection_data,
278278
)
279279

280+
if not license_detection:
281+
project.add_error(
282+
model="update_or_create_license_detection",
283+
details=detection_data,
284+
resource=resource_path,
285+
)
286+
return
287+
280288
if resource_path:
281289
file_region = scancode.get_file_region(
282290
detection_data=detection_data,
@@ -290,8 +298,8 @@ def update_or_create_license_detection(
290298

291299
def _clean_license_detection_data(detection_data):
292300
detection_data = detection_data.copy()
293-
if "sample_matches" in detection_data:
294-
matches = detection_data.pop("sample_matches")
301+
if "reference_matches" in detection_data:
302+
matches = detection_data.pop("reference_matches")
295303
detection_data["matches"] = matches
296304
return detection_data
297305

scanpipe/tests/test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def test_scanpipe_project_model_delete_related_objects(self):
168168
"scanpipe.CodebaseRelation": 0,
169169
"scanpipe.CodebaseResource": 1,
170170
"scanpipe.DiscoveredDependency": 0,
171+
"scanpipe.DiscoveredLicense": 0,
171172
"scanpipe.DiscoveredPackage": 1,
172173
"scanpipe.DiscoveredPackage_codebase_resources": 1,
173174
"scanpipe.ProjectMessage": 0,

scanpipe/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ def test_scanpipe_views_project_views(self):
683683
with self.assertNumQueries(8):
684684
self.client.get(url)
685685

686-
with self.assertNumQueries(13):
686+
with self.assertNumQueries(14):
687687
self.client.get(self.project1.get_absolute_url())
688688

689689
@mock.patch("scanpipe.models.Run.execute_task_async")

0 commit comments

Comments
 (0)