Skip to content

Commit

Permalink
Rename resolved_dependencies to resolved_from_dependencies #1066
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jun 3, 2024
1 parent 66f0325 commit e30de4e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 5.0.6 on 2024-06-03 08:20
# Generated by Django 5.0.6 on 2024-06-03 11:32

import django.db.models.deletion
from django.db import migrations, models


Expand All @@ -15,6 +16,19 @@ class Migration(migrations.Migration):
old_name="resolved_to",
new_name="resolved_to_package",
),
migrations.AlterField(
model_name="discovereddependency",
name="resolved_to_package",
field=models.ForeignKey(
blank=True,
editable=False,
help_text="The resolved package for this dependency. If empty, it indicates the dependency is unresolved.",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="resolved_from_dependencies",
to="scanpipe.discoveredpackage",
),
),
migrations.AddField(
model_name="discoveredpackage",
name="children_packages",
Expand Down
2 changes: 1 addition & 1 deletion scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3386,7 +3386,7 @@ class DiscoveredDependency(
)
resolved_to_package = models.ForeignKey(
DiscoveredPackage,
related_name="resolved_dependencies",
related_name="resolved_from_dependencies",
help_text=_(
"The resolved package for this dependency. "
"If empty, it indicates the dependency is unresolved."
Expand Down
12 changes: 6 additions & 6 deletions scanpipe/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,21 +2124,21 @@ def test_scanpipe_discovered_dependency_model_many_to_many(self):
a_b = make_dependency(project, for_package=a, resolved_to_package=b)
b_c = make_dependency(project, for_package=b, resolved_to_package=c)

# *_packages fields return Package QuerySet
# *_packages fields return DiscoveredPackage QuerySet
self.assertEqual([b], list(a.children_packages.all()))
self.assertEqual([], list(a.parent_packages.all()))
self.assertEqual([c], list(b.children_packages.all()))
self.assertEqual([a], list(b.parent_packages.all()))
self.assertEqual([], list(c.children_packages.all()))
self.assertEqual([b], list(c.parent_packages.all()))

# *_dependencies fields return Dependency QuerySet
# *_dependencies fields return DiscoveredDependency QuerySet
self.assertEqual([a_b], list(a.declared_dependencies.all()))
self.assertEqual([], list(a.resolved_dependencies.all()))
self.assertEqual([], list(a.resolved_from_dependencies.all()))
self.assertEqual([b_c], list(b.declared_dependencies.all()))
self.assertEqual([a_b], list(b.resolved_dependencies.all()))
self.assertEqual([a_b], list(b.resolved_from_dependencies.all()))
self.assertEqual([], list(c.declared_dependencies.all()))
self.assertEqual([b_c], list(c.resolved_dependencies.all()))
self.assertEqual([b_c], list(c.resolved_from_dependencies.all()))

def test_scanpipe_discovered_dependency_model_is_vulnerable_property(self):
package = DiscoveredPackage.create_from_data(self.project1, package_data1)
Expand All @@ -2164,7 +2164,7 @@ def test_scanpipe_package_model_integrity_with_toolkit_package_model(self):
"compliance_alert",
"tag",
"declared_dependencies",
"resolved_dependencies",
"resolved_from_dependencies",
]

package_data_only_field = ["datasource_id", "dependencies"]
Expand Down

0 comments on commit e30de4e

Please sign in to comment.